Keeping filterbar selections
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();
SIGN IN To post a reply.
4 Replies
AD
Administrator
Syncfusion Team
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;
this.gridDataBoundGrid1.Refresh();
}
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
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.
AD
Administrator
Syncfusion Team
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 :-)
SIGN IN To post a reply.
- 4 Replies
- 1 Participant
-
AD Administrator
- Nov 25, 2005 09:17 AM UTC
- Nov 29, 2005 03:42 PM UTC