We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

old DisplayMember / ValueMember topic into filter combo box

Is there a new solution to this problem sincer the release of version 3.3? I am refereing to the problem highlighted in the forum link below where the filter displays the value memeber instead of the display memeber? http://64.78.18.34/Support/Forums/message.aspx?MessageID=8368 >Hi, >my gridboundcolumn with comboboxes obtains its Display- and ValueMember from an external table. >The DisplayMember is shown and the ValueMember is written (This works fine). > >In the filterbar combobox only the ValueMember is displayed now, though, this isn''t so good. > >In the attachement can be seen being filled like the filter comboboxes. > >Aggravating a predefined data view filter still is additionally that you must take into account. > >Gives it a solution,to include the DisplayMember of the comboboxes, into the filterbar combobox? > >greetings markus

11 Replies

AD Administrator Syncfusion Team December 13, 2005 06:29 PM UTC

If you are using a GridDataBoundGrid, there is no new solution. But if you use a GirdGroupingControl, then that control supports filtering by display member.


VI vijay.sagar December 13, 2005 07:33 PM UTC

I am using GirdGroupingControl. Is there a sample of this showing how to implement filters using Value memebers and Display memebers? >If you are using a GridDataBoundGrid, there is no new solution. But if you use a GirdGroupingControl, then that control supports filtering by display member.


AD Administrator Syncfusion Team December 13, 2005 08:27 PM UTC

Check out this sample. \Essential Studio\3.3.0.0\Windows\Grid.Windows\Samples\Grouping\ForeignKeyReference


VI vijay.sagar December 13, 2005 08:45 PM UTC

I looked at that sample. It doesn''t seem to use a filterbar. I can see the of foriegn key but what about usage of the filterbar with the foreign key? Have you got a sample for this? Thanks Vijay >Check out this sample. >\Essential Studio\3.3.0.0\Windows\Grid.Windows\Samples\Grouping\ForeignKeyReference


VI vijay.sagar December 13, 2005 09:00 PM UTC

Perhaps the forum that I quoted wasn''t too clear about explaining the problem: http://64.78.18.34/Support/Forums/message.aspx?MessageID=8368 Let me explain this again: I am using a grouping grid where the underlying data consists of IDs/integers (Value members). All Values in the grid are displayed as meaningful names by mapping them to lookups using combo boxes. The lookups are sourced from another table. This works well when the values need to be changed to some other pre-defined value that is in the subset provided by the lookup. Any changes to the underlying DataTable are in the form of IDs which can be easily saved to the database maintaining integrity. The problem I am having is that with this setup, the filterbar only works with the underlying IDs (value memebers) and displays underlying IDs. The users of the app would like to filter by user friendly names (provided by lookups) instead of the IDs that represent them. My understanding is that there is a way to do this in the grouping grid. Do you have a sample? Thanks Vijay >I looked at that sample. It doesn''t seem to use a filterbar. I can see the of foriegn key but what about usage of the filterbar with the foreign key? Have you got a sample for this? > >Thanks > >Vijay > >>Check out this sample. >>\Essential Studio\3.3.0.0\Windows\Grid.Windows\Samples\Grouping\ForeignKeyReference


VI vijay.sagar December 14, 2005 02:18 PM UTC

Any progress on a sample for the problem discribed below: Perhaps the forum that I quoted wasn''''t too clear about explaining the problem: http://64.78.18.34/Support/Forums/message.aspx?MessageID=8368 Let me explain this again: I am using a grouping grid where the underlying data consists of IDs/integers (Value members). All Values in the grid are displayed as meaningful names by mapping them to lookups using combo boxes. The lookups are sourced from another table. This works well when the values need to be changed to some other pre-defined value that is in the subset provided by the lookup. Any changes to the underlying DataTable are in the form of IDs which can be easily saved to the database maintaining integrity. The problem I am having is that with this setup, the filterbar only works with the underlying IDs (value members) and displays underlying IDs. The users of the app would like to filter by user friendly names (provided by lookups) instead of the IDs that represent them. My understanding is that there is a way to do this in the grouping grid. Do you have a sample for version 3.3? Thanks Vijay >Perhaps the forum that I quoted wasn''t too clear about explaining the problem: > >http://64.78.18.34/Support/Forums/message.aspx?MessageID=8368 > >Let me explain this again: > >I am using a grouping grid where the underlying data consists of IDs/integers (Value members). All Values in the grid are displayed as meaningful names by mapping them to lookups using combo boxes. The lookups are sourced from another table. This works well when the values need to be changed to some other pre-defined value that is in the subset provided by the lookup. Any changes to the underlying DataTable are in the form of IDs which can be easily saved to the database maintaining integrity. > >The problem I am having is that with this setup, the filterbar only works with the underlying IDs (value memebers) and displays underlying IDs. The users of the app would like to filter by user friendly names (provided by lookups) instead of the IDs that represent them. My understanding is that there is a way to do this in the grouping grid. Do you have a sample? > >Thanks > >Vijay > >>I looked at that sample. It doesn''t seem to use a filterbar. I can see the of foriegn key but what about usage of the filterbar with the foreign key? Have you got a sample for this? >> >>Thanks >> >>Vijay >> >>>Check out this sample. >>>\Essential Studio\3.3.0.0\Windows\Grid.Windows\Samples\Grouping\ForeignKeyReference


AD Administrator Syncfusion Team December 14, 2005 04:12 PM UTC

The foriegnkey sample I referenced above is what you should use. If you add a filterbar to it, you will see the filter dropdown contains the Display Values and not the IDs. Here is that sample modified with teh lines to add a filterbar. http://www.syncfusion.com/Support/user/uploads/CS_dc87b8a6.zip


AD Administrator Syncfusion Team December 14, 2005 04:24 PM UTC

Here is another forum thread with a sample on using foreignkeys with datatables. Now it does not have a FilterBar, but if you add one like I did in the previous sample, I would expect it to display the DisplayValues in the FilterBar dropdown. http://www.syncfusion.com/Support/user/uploads/GGC_ForeignKeyReference_a924c4a.zip


VI vijay.sagar December 19, 2005 08:40 PM UTC

Thanks for yuor input and helping me figure it out. I have got it working but I still have one problem: In my application the user has the ability to add additional foreign keys (additional lookup values). In order for the additional lookups to appear in the dropdown filter and mapped combobox, I am rebuilding the tabledescripter with a new relation descriptor object. However, this is not producing any of the newly added items in the drop-down. Do I need to rebuild every single descriptor in the grid re-initialisation method all over again? I am trying to avoid doing that as it involves a lot of functionality to initialise the grid. If this is not the way could you please suggest another way. Thanks, Vijay >Here is another forum thread with a sample on using foreignkeys with datatables. Now it does not have a FilterBar, but if you add one like I did in the previous sample, I would expect it to display the DisplayValues in the FilterBar dropdown. > >http://www.syncfusion.com/Support/user/uploads/GGC_ForeignKeyReference_a924c4a.zip


ST stanleyj Syncfusion Team December 20, 2005 12:42 PM UTC

Hi Vijay, If you could upload a sample, we could try suggesting solutions. Best regards, Stanley


VI vijay.sagar December 20, 2005 03:07 PM UTC

My code currently hits an oracle database - so posting some sample code may require me do quite a bit of re-organising and hence some time. However, I have pasted the method I call whenever I initialize the grid (below). The task is to display all modified items by filtering. I am currently using DataViews with the filter capability associated with the underlying DataTable. Once the underlying DataView was changed, I would call InitializeGroupingGrid() to reset all the properties. This was working fine until I introduced the foreign keys into the InitializeGroupingGrid() method. Is there another way to filter and show modified rows only without using the DataView? Thanks Vijay private void InitializeGroupingGrid(int refresh, DataView dview) /// { string ForeignRelationName, ForeignDisplayCol; int ForeignColIndex; try { this.grid.BeginUpdate(); GridTableDescriptor td = this.grid.TableDescriptor; td.Name = "Update Rating"; this.grid.DataSource = dview; #region SetUp RATING foreign key //step 1. remember the location of lookupcol so it can be swapped out later ForeignRelationName = "Assigned"; ForeignDisplayCol = "RATING"; ForeignColIndex = td.VisibleColumns.IndexOf(ForeignRelationName + "_" + ForeignDisplayCol); if (ForeignColIndex != -1) td.VisibleColumns.RemoveAt(ForeignColIndex); lookUpIndex = td.VisibleColumns.IndexOf("RATING_ID"); //step 2. add it to the grouping engine this.grid.Engine.SourceListSet.Add(dsRatings.Tables["Ratings"].TableName, dsRatings.Tables["Ratings"].DefaultView); //step 3. Create and setup a RelationKind.ForeignKeyReference relation //set up relation descriptor that defines mapping between main table and foreign table GridRelationDescriptor RatingRD = new GridRelationDescriptor(); RatingRD.Name = "Assigned"; //just some unique name RatingRD.RelationKind = RelationKind.ForeignKeyReference; //foreign key look up RatingRD.ChildTableName = dsRatings.Tables["Ratings"].TableName; // SourceListSet name for lookup //get foreign key for col "idCol" in foreign table RatingRD.RelationKeys.Add("RATING_ID", "RATING_ID"); //col in main table, foreign key col //step 4. Set any optional properties on the relation // dropdown only shows DisplayCol RatingRD.ChildTableDescriptor.VisibleColumns.Add("RATING"); //display column RatingRD.ChildTableDescriptor.SortedColumns.Add("RATING"); //sort it for dropdown display RatingRD.ChildTableDescriptor.AllowEdit = false; //no editing of foreign table RatingRD.ChildTableDescriptor.AllowNew = false; //no new items added to foreign table //step 5. add relation descriptor to main tabledescriptor td.Relations.Add(RatingRD); //step 6. Replace maintable.LookUpCol with foreigntable.DisplayCol //get the hashed name of foreign col RATING_FOREIGN_COLUMN = RatingRD.Name + "_" + "RATING"; td.VisibleColumns.Insert(lookUpIndex, RATING_FOREIGN_COLUMN); #endregion #region SetUp SOURCE foreign key //step 1. remember the location of lookupcol so it can be swapped out later ForeignRelationName = "Source"; ForeignDisplayCol = "NAME"; ForeignColIndex = td.VisibleColumns.IndexOf(ForeignRelationName + "_" + ForeignDisplayCol); if (ForeignColIndex != -1) td.VisibleColumns.RemoveAt(ForeignColIndex); lookUpIndex = td.VisibleColumns.IndexOf("SOURCE_ID"); //step 2. add it to the grouping engine this.grid.Engine.SourceListSet.Add(dsSourcesData.Tables["Sources"].TableName, dsSourcesData.Tables["Sources"].DefaultView); //step 3. Create and setup a RelationKind.ForeignKeyReference relation //set up relation descriptor that defines mapping between main table and foreign table GridRelationDescriptor SourceRD = new GridRelationDescriptor(); SourceRD.Name = "Source"; //just some unique name SourceRD.RelationKind = RelationKind.ForeignKeyReference; //foreign key look up SourceRD.ChildTableName = dsSourcesData.Tables["Sources"].TableName; // SourceListSet name for lookup //get foreign key for col "idCol" in foreign table SourceRD.RelationKeys.Add("SOURCE_ID", "ID"); //col in main table, foreign key col //step 4. Set any optional properties on the relation // dropdown only shows DisplayCol SourceRD.ChildTableDescriptor.VisibleColumns.Add("NAME"); //display column SourceRD.ChildTableDescriptor.SortedColumns.Add("NAME"); //sort it for dropdown display SourceRD.ChildTableDescriptor.AllowEdit = false; //no editing of foreign table SourceRD.ChildTableDescriptor.AllowNew = false; //no new items added to foreign table //step 5. add relation descriptor to main tabledescriptor td.Relations.Add(SourceRD); //step 6. Replace maintable.LookUpCol with foreigntable.DisplayCol //get the hashed name of foreign col SOURCE_FOREIGN_COLUMN = SourceRD.Name + "_" + "NAME"; td.VisibleColumns.Insert(lookUpIndex, SOURCE_FOREIGN_COLUMN); #endregion } this.grid.QueryCellStyleInfo += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventHandler(grid_QueryCellStyleInfo); foreach (GridColumnDescriptor ColDesc in this.grid.TableDescriptor.Columns) ColDesc.Appearance.AnyRecordFieldCell.CellType = "Static"; #region Attach LookUps this.grid.TableDescriptor.Columns[SOURCE_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.CellType = "ComboBox"; this.grid.TableDescriptor.Columns[SOURCE_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.ChoiceList = null; this.grid.TableDescriptor.Columns[SOURCE_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.WrapText = false; this.grid.TableDescriptor.Columns[SOURCE_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.AutoSize = true; this.grid.TableDescriptor.Columns[SOURCE_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.DropDownStyle = GridDropDownStyle.AutoComplete; this.grid.TableDescriptor.Columns[SOURCE_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.DataSource = dsSourcesData.Tables["Sources"]; this.grid.TableDescriptor.Columns[SOURCE_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.DisplayMember = "NAME"; this.grid.TableDescriptor.Columns[SOURCE_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.ValueMember = "ID"; this.grid.TableDescriptor.Columns[SOURCE_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.Enabled = false; this.grid.TableDescriptor.Columns[SOURCE_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.ShowButtons = GridShowButtons.ShowCurrentCellEditing; this.grid.TableDescriptor.Columns[SOURCE_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.CellAppearance = Syncfusion.Windows.Forms.Grid.GridCellAppearance.Raised; this.grid.TableDescriptor.Columns[SOURCE_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Left; this.grid.TableDescriptor.Columns[RATING_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.CellType = "ComboBox"; this.grid.TableDescriptor.Columns[RATING_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.ChoiceList = null; this.grid.TableDescriptor.Columns[RATING_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.WrapText = false; this.grid.TableDescriptor.Columns[RATING_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.AutoSize = true; this.grid.TableDescriptor.Columns[RATING_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.DropDownStyle = GridDropDownStyle.AutoComplete; this.grid.TableDescriptor.Columns[RATING_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.DataSource = dsRatings.Tables["Ratings"]; this.grid.TableDescriptor.Columns[RATING_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.DisplayMember = "RATING"; this.grid.TableDescriptor.Columns[RATING_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.ValueMember = "RATING_ID"; this.grid.TableDescriptor.Columns[RATING_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.ShowButtons = GridShowButtons.ShowCurrentCellEditing; this.grid.TableDescriptor.Columns[RATING_FOREIGN_COLUMN].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Left; #endregion #region Define Visible Columns td.VisibleColumns.Remove("ISSUER"); td.VisibleColumns.Remove("SOURCE"); td.VisibleColumns.Remove("RATING"); td.VisibleColumns.Remove("PRODUCT_SUB_TYPE"); //td.VisibleColumns.Remove("MDS_CODE"); #endregion this.grid.RecordValueChanged += new Syncfusion.Grouping.RecordValueChangedEventHandler(grid_RecordValueChanged); this.grid.TableControl.CurrentCellAcceptedChanges += new System.ComponentModel.CancelEventHandler(grid_CurrentCellAcceptedChanges); this.grid.ChildGroupOptions.CaptionText = "{CategoryName}: {Category} ----- {RecordCount} Items "; #region Add Filterbars //allow filterbar entries this.grid.TopLevelGroupOptions.ShowFilterBar = true; this.grid.TableDescriptor.Columns[ISSUER_FOREIGN_COLUMN].AllowFilter = true; this.grid.TableDescriptor.Columns["ISSUER_LONG_NAME"].AllowFilter = true; this.grid.TableDescriptor.Columns[SOURCE_FOREIGN_COLUMN].AllowFilter = true; this.grid.TableDescriptor.Columns[RATING_FOREIGN_COLUMN].AllowFilter = true; this.grid.TableDescriptor.Columns[PrSubType_FOREIGN_COLUMN].AllowFilter = true; this.grid.TableDescriptor.Columns["MDS_CODE"].AllowFilter = true; this.grid.TableDescriptor.Columns[Sector_FOREIGN_COLUMN].AllowFilter = true; this.grid.TableDescriptor.Columns["DEFAULT_IND"].AllowFilter = true; this.grid.TableDescriptor.Columns["STATUS"].AllowFilter = true; //add a custom cell type #endregion #region Define Headers td.Columns[ISSUER_FOREIGN_COLUMN].HeaderText = "Issuer"; td.Columns[ISSUER_FOREIGN_COLUMN].Width = 240; td.Columns["ISSUER_LONG_NAME"].HeaderText = "*Long Name"; td.Columns["ISSUER_LONG_NAME"].Appearance.ColumnHeaderCell.TextColor = Color.DarkBlue; td.Columns["ISSUER_LONG_NAME"].Width = 270; td.Columns[SOURCE_FOREIGN_COLUMN].HeaderText = "*Source"; td.Columns[SOURCE_FOREIGN_COLUMN].Appearance.ColumnHeaderCell.TextColor = Color.DarkBlue; td.Columns[SOURCE_FOREIGN_COLUMN].Width = 170; td.Columns[RATING_FOREIGN_COLUMN].HeaderText = "Rating"; td.Columns[RATING_FOREIGN_COLUMN].Width = 60; td.Columns["STATUS"].HeaderText = "*Status"; td.Columns["MDS_CODE"].HeaderText = "MDS CODE"; td.Columns["MDS_CODE"].Width = 100; td.Columns[PrSubType_FOREIGN_COLUMN].HeaderText = "Product SubType"; td.Columns[PrSubType_FOREIGN_COLUMN].Width = 200; td.Columns[Sector_FOREIGN_COLUMN].HeaderText = "Sector"; td.Columns[Sector_FOREIGN_COLUMN].Width = 70; td.Columns["DEFAULT_IND"].HeaderText = "Default"; td.Columns["DEFAULT_IND"].Width = 65; this.grid.TableOptions.RowHeaderWidth = 35; #endregion //use to catch right-click on an inactive cell this.grid.TableControlCellMouseUp += new GridTableControlCellMouseEventHandler(grid_TableControlCellMouseUp); this.grid.EndUpdate(true); } #region Handle Exception catch (Exception ex) { MessageBox.Show( "[InitializeGroupingGrid]"+ex.Message+"" ); NameValueCollection info = new NameValueCollection(); info.Add("Method", "InitializeGroupingGrid"); ExceptionManager.Publish(ex, info); } finally { } #endregion } >Hi Vijay, > >If you could upload a sample, we could try suggesting solutions. > >Best regards, >Stanley

Loader.
Live Chat Icon For mobile
Up arrow icon