This is a migrated thread and some comments may be shown as answers.

Save Grid Layout

2 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 24 Apr 2008, 08:52 AM
Hi,
My users are changing the grid client-side (sort, filter, column order, etc).
What i would like to do is be able to save the grid layout, so when the page is reloaded, i can load these settings, so the grid looks the same as when the user left it. Is this possible ?
To xml or database ???

Thanks in advance
Mark

2 Answers, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 1
answered on 24 Apr 2008, 08:55 AM
Doh...
Just read a thread that explains exactly how to do this..
http://www.telerik.com/help/radcontrols/prometheus/grdSavingSettingsOnPerUserBasis.html

Just ignore me !!!

Thanks
Mark
0
Accepted
Mike
Top achievements
Rank 1
answered on 31 Jul 2008, 04:08 PM
Mark,

This is really easy, try this.

aspx Page:

 <asp:Button ID="Button1" Text="Save Grid Settings" OnClick="ButtonSave_Click" Width="120" runat="server" /> 

Code Behind:

protected void Page_Init(object sender, EventArgs e)  
 {  
  GridSettingsPersister settings = new GridSettingsPersister(RadGrid1);  
  if (Request.Cookies["RadGrid1Settings"] != null)  
    {  
     settings.LoadSettings(Convert.ToString(Request.Cookies["RadGrid1Settings"]["Data"]));  
    }  
 } 

    protected void ButtonSave_Click(Object obj, EventArgs e)  
    {  
        GridSettingsPersister settings = new GridSettingsPersister(RadGrid1);      
        Response.Cookies["RadGrid1Settings"]["Data"] = Convert.ToString(settings.SaveSettings());  
        Response.Cookies["RadGrid1Settings"]["Time"] = DateTime.Now.ToString("G");  
        Response.Cookies["RadGrid1Settings"].Expires = DateTime.Now.AddMonths(1);  
       // Label1.Text = "Cookie created!<p>" + "Your cookie contains:<font color=red>" + Request.Cookies["RadGrid1Settings"]["Data"] + "<br>" + Request.Cookies["RadGrid1Settings"]["Time"] + "</font>";  
    } 

Now my settings persist for 30 days.  If you want you can make a drop down for the length of time (days, months, years, etc.) to save the settings or until the user deletes their cookie.

This is a very simple approach but it works like a charm.
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Mark
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Share this question
or