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.

Filter on Gridboundcolumns

Thread ID:

Created:

Updated:

Platform:

Replies:

103878 Jun 6,2012 10:36 AM Jun 18,2012 11:36 PM Windows Forms 3
loading
Tags: GridControl
Paul Mulder
Asked On June 6, 2012 10:36 AM

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.

 


Ragamathulla B [Syncfusion]
Replied On June 7, 2012 12:17 AM

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.


Paul Mulder
Replied On June 18, 2012 04:08 PM

Thank you. Solved it


Ragamathulla B [Syncfusion]
Replied On June 18, 2012 11:36 PM

Hi Paul,

Thanks for the update.

Please let me know if you have any further concerns.

Regards,

Ragamathullah B.


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.

;