
Andrei Catalin
Top achievements
Rank 1
Andrei Catalin
asked on 09 Jul 2009, 01:15 PM
Hello,
I work on a project in which I have a radgrid on the main page. On this radgrid a've activated the filter & sort commands. What I would like to do, is to preserve somewhere (in session, viewstate, etc) the state of the filter columns & sort columns (If the user has put some filters, or if the user has sorted the grid by some columns) so when in the future I'll be back on the main page, to put them (the filters & the sort columns) back.
Can this be done?
Have a nice day,
Catalin
I work on a project in which I have a radgrid on the main page. On this radgrid a've activated the filter & sort commands. What I would like to do, is to preserve somewhere (in session, viewstate, etc) the state of the filter columns & sort columns (If the user has put some filters, or if the user has sorted the grid by some columns) so when in the future I'll be back on the main page, to put them (the filters & the sort columns) back.
Can this be done?
Have a nice day,
Catalin
8 Answers, 1 is accepted
0
Hi Andrei,
Such functionality can easily be achieved by saving the RadGrid.MasterTableView.FilterExpression string and the strings in the RadGrid1.MasterTableView.SortExpressions collection. You can save your values in the Session state or browser cookies, but not on the ViewState, as the latter is lost on initial page load, meaning it will be lost the moment you navigate away from the page.
RadGrid's PreRender event is most suitable for saving filter and sort expressions, and the Page_Load event is the place where you can restore your settings next time your user navigates to your main page.
All the best,
Veli
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Such functionality can easily be achieved by saving the RadGrid.MasterTableView.FilterExpression string and the strings in the RadGrid1.MasterTableView.SortExpressions collection. You can save your values in the Session state or browser cookies, but not on the ViewState, as the latter is lost on initial page load, meaning it will be lost the moment you navigate away from the page.
RadGrid's PreRender event is most suitable for saving filter and sort expressions, and the Page_Load event is the place where you can restore your settings next time your user navigates to your main page.
All the best,
Veli
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Sabby
Top achievements
Rank 1
answered on 09 Jul 2010, 11:26 PM
Hi !
i have this in my PreRender event
Session["rgListSortExpressions"] = rgList.MasterTableView.SortExpressions;
and on page load i am using this
GridSortExpression expression = (GridSortExpression)Session["rgListSortExpressions"];
rgList.MasterTableView.SortExpressions.Add(expression);
but still i am getting this error
Unable to cast object of type 'Telerik.Web.UI.GridSortExpressionCollection' to type 'Telerik.Web.UI.GridSortExpression'.
Kindly help me in this,
Thanks in Advance.
i have this in my PreRender event
Session["rgListSortExpressions"] = rgList.MasterTableView.SortExpressions;
and on page load i am using this
GridSortExpression expression = (GridSortExpression)Session["rgListSortExpressions"];
rgList.MasterTableView.SortExpressions.Add(expression);
but still i am getting this error
Unable to cast object of type 'Telerik.Web.UI.GridSortExpressionCollection' to type 'Telerik.Web.UI.GridSortExpression'.
Kindly help me in this,
Thanks in Advance.
0
Hello Sabby,
You are trying to cast a collection of sort expressions to a single sort expression object. Besides, it is not recommended to save and load entire sort expression collections. Instead, try to save and load the Field names and sort order in each sort expression.
Regards,
Veli
the Telerik team
You are trying to cast a collection of sort expressions to a single sort expression object. Besides, it is not recommended to save and load entire sort expression collections. Instead, try to save and load the Field names and sort order in each sort expression.
Regards,
Veli
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0

Sabby
Top achievements
Rank 1
answered on 12 Jul 2010, 06:53 PM
Hi,
I resolved my problem by casting the session variable into GridSortExpressionCollection.
Thanks for the help.
I resolved my problem by casting the session variable into GridSortExpressionCollection.
Thanks for the help.
0

Alex
Top achievements
Rank 1
answered on 17 Nov 2010, 10:46 AM
Hello
Yes, storing FilterExpression in session variable and retreiving back on Page_Load was good idea. Looks like fiters are saved successfully - I see that when I back to the page. Thank you. But fiter row becomes in initial state, that is if I had filter Name = "Alex" I see records dispaing Alex only, but filter field itself is empty.
Do you have a solution how can I parse FilterExpression to init all my filters fileds? Moreover, some of them are dropdowns, checkboxes e.t.c.
Than you for your help
Alex
Yes, storing FilterExpression in session variable and retreiving back on Page_Load was good idea. Looks like fiters are saved successfully - I see that when I back to the page. Thank you. But fiter row becomes in initial state, that is if I had filter Name = "Alex" I see records dispaing Alex only, but filter field itself is empty.
Do you have a solution how can I parse FilterExpression to init all my filters fileds? Moreover, some of them are dropdowns, checkboxes e.t.c.
Than you for your help
Alex
0
Hi Alex,
Consider the RadGrid Persisting Grid Settings Demo. You can use the GridSettingsPersister class as shown there to persist the grid settings, including the filter expression, filter value and filter function for each column. To persist the filtering item data in RadGrid, you need to save and load each column's CurrentFilterFunction and CurrentFilterValue. The GridSettingsPersister does the job for you.
Veli
the Telerik team
Consider the RadGrid Persisting Grid Settings Demo. You can use the GridSettingsPersister class as shown there to persist the grid settings, including the filter expression, filter value and filter function for each column. To persist the filtering item data in RadGrid, you need to save and load each column's CurrentFilterFunction and CurrentFilterValue. The GridSettingsPersister does the job for you.
Veli
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Alex
Top achievements
Rank 1
answered on 18 Nov 2010, 08:34 AM
Hi Veli
Thank you for your help - looks like that is it I am looking for.
Alex
Thank you for your help - looks like that is it I am looking for.
Alex
0

Simone
Top achievements
Rank 1
answered on 05 Mar 2012, 09:31 PM
Hello,
That GridSettingsPersister class worked well for me. Just wanted to post my code, in case it helps somebody. It saves the grid settings whenever user leaves the page, and when the user comes back, the settings are applied back.
Thanks.
protected void Page_Load(object sender, System.EventArgs e)
{
GridSettingsPersister LoadPersister = new GridSettingsPersister(grdReps);
if (Session["GridSettings"] != null)
{
string settings = (string)Session["GridSettings"];
LoadPersister.LoadSettings(settings);
}
}
protected void Page_Unload(object sender, System.EventArgs e)
{
GridSettingsPersister SavePersister = new GridSettingsPersister(grdReps);
Session["GridSettings"] = SavePersister.SaveSettings();
}
That GridSettingsPersister class worked well for me. Just wanted to post my code, in case it helps somebody. It saves the grid settings whenever user leaves the page, and when the user comes back, the settings are applied back.
Thanks.
protected void Page_Load(object sender, System.EventArgs e)
{
GridSettingsPersister LoadPersister = new GridSettingsPersister(grdReps);
if (Session["GridSettings"] != null)
{
string settings = (string)Session["GridSettings"];
LoadPersister.LoadSettings(settings);
}
}
protected void Page_Unload(object sender, System.EventArgs e)
{
GridSettingsPersister SavePersister = new GridSettingsPersister(grdReps);
Session["GridSettings"] = SavePersister.SaveSettings();
}