GridFilterBar and DataTable with foreign keys

I have a main table that contains columns with foreign keys to other tables.
I display the main table in a GridDataBoundGrid and add a GridFilterBar to it.
I can also display meaningful values (Bonds as as opposed to 3, let's say) in the grid
(instead of the foreign keys) doing:

GridBoundColumnsCollection gbcc = this.thePositionsGrid.Binder.InternalColumns;
gbcc["ProductTypeID"].StyleInfo.CellType = "ComboBox";
gbcc["ProductTypeID"].StyleInfo.DataSource = thePositionsDataController.GetProductTypeTable();
gbcc["ProductTypeID"].StyleInfo.DisplayMember = "ProductTypeName";
gbcc["ProductTypeID"].StyleInfo.ValueMember = "ProductTypeID";
gbcc["ProductTypeID"].StyleInfo.ShowButtons = GridShowButtons.Show;
gbcc["ProductTypeID"].HeaderText = "Type";

At this stage, my GridFilterBar still displays the foreign keys as options for filtering.
The filter still works properly though.
I can display the meaningful values instead by doing:

int col = this.thePositionsGrid.Binder.NameToColIndex("ProductTypeID");
DataTable filterTable = (DataTable) this.thePositionsGrid[1,col].DataSource;
DataTable inputTable = thePositionsDataController.GetProductTypeTable(); // table with related primary keys
int nbrOfRows = filterTable.Rows.Count;
for (int i = 2; i < nbrOfRows;++i)
filterTable.Rows[i][0] = inputTable.Rows[i-2]["ProductTypeName"];

But then the filter is not working properly anymore.

Can you tell the most effective way to display a table with foreign keys in a GridDataBoundGrid,
replace the foreign keys by meaningful values to the user and be able to filter based on these meaningful values?

Thanks

1 Reply

RA Rajagopal Syncfusion Team October 25, 2007 07:26 PM UTC

Hi Stephane,

You can derive the GridFilterBar and override the WireGrid and GetFilterFromRow to achieve this. Please refer the following sample that helps in doing this.

http://websamples.syncfusion.com/samples/Grid.Windows/F69174/main.htm

Let us know if you have any questions.

Thanks for your patience.

Regards,
Rajagopal

Loader.
Up arrow icon