GridFilterBar updates

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


1 Reply

HA haneefm Syncfusion Team January 23, 2008 06:18 PM UTC

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



Loader.
Up arrow icon