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. (Last updated on: November 16, 2018).
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 06:24 AM UTC Jan 23,2008 06:18 PM UTC WinForms 1
loading
Tags: GridControl
Sabareesh Krishnamoorthy
Asked On January 22, 2008 06:24 AM UTC

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



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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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

;