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.
Unfortunately, activation email could not send to your email. Please try again.

GridFilterBar and DataTable with foreign keys

Thread ID:

Created:

Updated:

Platform:

Replies:

69174 Oct 17,2007 10:43 AM Oct 25,2007 03:26 PM Windows Forms 1
loading
Tags: Chart
Stephane Dapsanse
Asked On October 17, 2007 10:43 AM

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

Rajagopal [Syncfusion]
Replied On October 25, 2007 03:26 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;