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
close icon

Filter on Gridboundcolumns

I want to filter a databoundgridcolumn (dropdown type) based on another databoundgridcolumn (also dropdown type).

In other words, I select first column from dropdown (that is linked to a bindingsource for values), which in turn limits the choices on the second column dropdown (also linked to a different bindingsource) based on the first selection.

For ease of understanding, the first column could be country and the second column could be state. There are no relations set up between these datasources, but should it be required, I could probably look into that.

 


3 Replies

RB Ragamathulla B Syncfusion Team June 7, 2012 04:17 AM UTC

Hi Paul,

Thank you for your interest in syncfusion products.

You can bind the datasource dynamically based on the selected value inside ‘CurrentCellShowedDropDown’ event. The following code explains the same.

void gridDataBoundGrid1_CurrentCellShowedDropDown(object sender, EventArgs e)
{
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
if (cc.ColIndex == 2)
//column that need to be filtered...
{
GridComboBoxCellRenderer cr = (GridComboBoxCellRenderer)cc.Renderer;
if (cr != null)
{
string text = gridDataBoundGrid1[cc.RowIndex, 1].Text;
if (text == "One")
{
((GridComboBoxListBoxPart)cr.ListBoxPart).DataSource = GetTable1();
((GridComboBoxListBoxPart)cr.ListBoxPart).DisplayMember = "Col2";
((GridComboBoxListBoxPart)cr.ListBoxPart).ValueMember = "Col1";
}
else
{
((GridComboBoxListBoxPart)cr.ListBoxPart).DataSource = GetTable();
((GridComboBoxListBoxPart)cr.ListBoxPart).DisplayMember = "Col1";
((GridComboBoxListBoxPart)cr.ListBoxPart).ValueMember = "Col2";
}
}

}
}

Please refer to the following sample which illustrates the same.

http://www.syncfusion.com/downloads/Support/DirectTrac/87557/ComboBoxGDBG-2065197015.zip

Please let me know if you have any further concerns.

Regards,
Ragamathullah B.



PM Paul Mulder June 18, 2012 08:08 PM UTC

Thank you. Solved it



RB Ragamathulla B Syncfusion Team June 19, 2012 03:36 AM UTC

Hi Paul,

Thanks for the update.

Please let me know if you have any further concerns.

Regards,

Ragamathullah B.


Loader.
Live Chat Icon For mobile
Up arrow icon