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.
Syncfusion Feedback

GridFilterBar updates

Thread ID:

Created:

Updated:

Platform:

Replies:

71201 Jan 22,2008 01:24 AM Jan 23,2008 01:18 PM Windows Forms 1
loading
Tags: GridControl
Sabareesh Krishnamoorthy
Asked On January 22, 2008 01:24 AM

Hello All,

I'm using the GridFilterBar wired to a data bound grid. The problem i'm facing is that the Filterbar does not get updated with the values as they are added to the grid after the filterbar is wired.

is there a work around for the issue?

Thanks and regards,
-Sabareesh


haneefm [Syncfusion]
Replied On January 23, 2008 01:18 PM

Hi Sabareesh,

To update the filterbar dropdown values in a GridDataBoundGrid, you need to handle the CurrentCellShowingDropDown event and set the ListBoxPart.DataSource of the filterbar using below code snippet. Please try this and let me know if this helps.

void gridDataBoundGrid1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
GridDataBoundGrid grid = sender as GridDataBoundGrid;

GridCurrentCell cc = grid.CurrentCell;
if (cc != null && cc.RowIndex == 1 )
{
GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
int field = grid.Binder.ColIndexToField(cc.ColIndex);
string colName = grid.Binder.InternalColumns[field].MappingName;
DataTable dt = grid.DataSource as DataTable;
cr.ListBoxPart.DataSource = CreateUniqueEntry( dt.DefaultView , colName );

}
}

private DataTable CreateUniqueEntry(DataView dv, string colName)
{
DataRow dr;
DataTable dt = new DataTable(colName);
dt.Columns.Add(new DataColumn(colName));

dr = dt.NewRow();
dr[0] = "(none)";
dt.Rows.Add(dr);

dr = dt.NewRow();
dr[0] = "(custom)";
dt.Rows.Add(dr);

string s = "";
for (int i = 0; i < dv.Count; ++i)
{
if (s != dv[i].Row[colName].ToString().ToUpper())
{
s = dv[i].Row[colName].ToString();
dr = dt.NewRow();
dr[0] = s;
dt.Rows.Add(dr);
}
}
return dt;
}

Best regards,
Haneef



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.

Warning Icon 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.Close Icon

;