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

Keeping filterbar selections

Thread ID:





37574 Nov 25,2005 09:17 AM UTC Nov 29,2005 03:42 PM UTC WinForms 4
Tags: GridControl
Administrator [Syncfusion]
Asked On November 25, 2005 09:17 AM UTC

Hi Syncfusion, I have a problem with a GridDataBoundGrid that has a filterbar attached. In the grid I need to make copies of exiting rows, which are inserted into the grid again. F.i: Before: Column Headers: [ID] [Name] [Code] Filterbar: [] [] [] Data: 1 name1 code1 2 name2 code2 Now copy row with id = 1. After: Column Headers: [ID] [Name] [Code] Filterbar: [] [] [] Data: 1 name1 code1 2 name2 code2 1 name1 code1 Now I use the filterbar: Before: Column Headers: [ID] [Name] [Code] Filterbar: [] [name2] [] Data: 2 name2 code2 Now copy row with id = 2 After: Column Headers: [ID] [Name] [Code] Filterbar: [] [name2] [] Data: 2 name2 code2 2 name2 code2 My question is: How do i preserve [name2] in the filterbar, when I need to update the grid due to the new row? My update grid code looks like this: this.Grid.BeginUpdate(); if (this.filterBar != null && this.filterBar.Wired) { rowFilter = this.filterBar.RowFilter; // preserve rowfilter so that i can be applied after update this.filterBar.UnwireGrid(); } this.Grid.DataSource = null; // Do some stuff this.Grid.DataSource = datasource; this.filterBar.WireGrid(this.Grid); this.Grid.EndUpdate();

Administrator [Syncfusion]
Replied On November 25, 2005 10:06 AM UTC

Try code like:
string saveFilter;
ArrayList saveStyles;
private void button4_Click(object sender, System.EventArgs e)
{  //save the filter settings
	saveStyles = new ArrayList();
	for(int col = 1; col <= this.gridDataBoundGrid1.Model.ColCount; ++col)
		saveStyles.Add(this.gridDataBoundGrid1.GetViewStyleInfo(1, col, true));
	this.saveFilter = this.theFilterBar.RowFilter;
private void button5_Click(object sender, System.EventArgs e)
{	//apply the saved filter settings
	for(int col = 1; col <= this.gridDataBoundGrid1.Model.ColCount; ++col)
		this.gridDataBoundGrid1[1, col] = saveStyles[col-1] as GridStyleInfo;
	this.theFilterBar.RowFilter = this.saveFilter;

Administrator [Syncfusion]
Replied On November 29, 2005 01:31 PM UTC

This does not solve the problem. Perhaps due to the fact that i''m using a filterbar with values like described in http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=34385

Administrator [Syncfusion]
Replied On November 29, 2005 01:57 PM UTC

Here is our sample modified with the above code showing it working for me using version 3.3 and later. I can click the save filter button, load another datasource, then reload the original datasource and then apply the saved filter. http://www.syncfusion.com/Support/user/uploads/CS_38faf3eb.zip If you can add your derived filterbar class to this sample, we can try to track down what is failing.

Administrator [Syncfusion]
Replied On November 29, 2005 03:42 PM UTC

Hi, I had to set the RowFilter on the original datasource to preserve my filtering: fslsGrid.DataSource = SomeDTO.entries.DefaultView; this.filterBar.WireGrid(this.fslsGrid); if (saveStyles.Count > 0) { // set filterbar selections again for(int col = 1; col <= this.fslsGrid.Model.ColCount; ++col) this.fslsGrid[1, col] = saveStyles[col-1] as GridStyleInfo; this.filterBar.RowFilter = rowFilter; this.SomeDTO.entries.DefaultView.RowFilter = rowFilter; this.fslsGrid.Refresh(); } thanks for your help :-)


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