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

GridFilterBar - filter items should change after each filter operation

Hello, after selecting a filter item for one column in the grid, the filter bar items should be updated according to the resulting data. This means, that the user is not able to select a filter item which corresponding data is already excluded with the first filter condition. I used a DataView object as the DataSource for the DataBoundGrid: this.gridDataBoundGrid1.DataSource = dvTest; In the event handler for FilterBarTextChanged I unwired the filter bar, changed the data view row filter, and wired the filter bar again to the grid. private void filterBar_FilterBarTextChanged(object sender, GridFilterBarTextChangedEventArgs e) { theFilterBar.UnwireGrid(); dvTest.RowFilter = theFilterBar.RowFilter; theFilterBar.WireGrid(gridDataBoundGrid1); label2.Text = theFilterBar.RowFilter; } This works except that the row filter after the WireGrid function is wrong (2 times the same entry). But the problem is now that after the next filter operation (different column) the previous filter condition is lost again. What can I do to solve these problems? Is there another "easy" way to solve it? Thx, for the help! Best Regards, Matt

6 Replies

AD Administrator Syncfusion Team January 19, 2005 03:02 PM UTC

Instead of dvTest.RowFilter = theFilterBar.RowFilter; Try this. dvTest.RowFilter = dvTest.RowFilter + " AND " + theFilterBar.RowFilter; theFilterBar.RowFilter = "";

AD Administrator Syncfusion Team January 20, 2005 09:07 AM UTC

Hi Clay, thx for your quick reply! This helps a little bit but finally I would like to achive the same behavior as in Excel sheet auto filters (with multiple columns). I attached my sample project. First of all the filter bar does not keep the selected filter values for the columns. Additionally it is not possible to set the filter for one column back to (none) -> event handler is not called any more. Pls, let me know if there is a known way to implement this behavior with the DataBoundGird. Thx, Matt >Instead of > >dvTest.RowFilter = theFilterBar.RowFilter; > >Try this. > >dvTest.RowFilter = dvTest.RowFilter + " AND " + theFilterBar.RowFilter; >theFilterBar.RowFilter = ""; > > > GridTestFilterBar_4346.zip

AD Administrator Syncfusion Team January 20, 2005 12:22 PM UTC

Try removing your FilterBarTextChanged event handler and replace it with a CurrentCellShowingDropDown event handler. It that handler dynamically build the list that you want to display.
private void gridDataBoundGrid1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;

	if(cc.RowIndex == 1 && cc.ColIndex > 0)
		GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
		ListBox lb = cr.ListBoxPart;

		DataTable dt = lb.DataSource as DataTable;
		string colName = dt.Columns[0].ColumnName;
		dt = new DataTable("MyTable");
		dt.Columns.Add(new DataColumn(colName));
		DataRow dr = dt.NewRow();
		dr[0] = "(none)";
		dr = dt.NewRow();
		dr[0] = "(custom)";
        foreach(DataRowView drv in this.dvTest)
			dr = dt.NewRow();
			dr[0] = drv[colName];
		lb.DataSource = dt;

AD Administrator Syncfusion Team January 21, 2005 06:01 AM UTC

Thx, this was exactly what I was searching for! Matt

SL Salvatore Lentini January 13, 2010 06:39 PM UTC

I am using a newer version of Syncfusion, version 5.2. It seems that once the filterbar is set to a value then set back to "(none)" the "(none)" string does not cause a FilterBarTextChanged event to be fired.

Is this a known issue?

JJ Jisha Joy Syncfusion Team January 18, 2010 09:49 AM UTC

Hi Salvatore,

Thank you for using Syncfusion products.

I am afraid that I was not able to reproduce the issue. I have created a simple sample to test this issue and it is available in the following link.
Please have a look at the sample attached and if still the issue exists, could you please try reproducing it
in the above sample or send us the reproducing steps so that we could sort out the cause of the issue
and provide you a solution?



Live Chat Icon For mobile
Up arrow icon