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

Saving Grid Settings Via Profile

1 Answer 128 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sompop
Top achievements
Rank 1
Sompop asked on 18 Oct 2011, 06:27 PM
Hi there,

I am following the code from the link below. It is great. However, there are two questions that I would like to ask.
http://www.telerik.com/community/code-library/preview-thread/aspnet-ajax/grid/storing-multiple-grid-settings-in-database-via-profile.aspx

1. When I turn on AllowFilterByColumn, it works fine when I re-login. However, it does not display the value in the filter TextBox or CheckBox. For example, I put "Net 60 Days" in the filter TextBox and select "Contains". After I re-login, I see the same result, but I don't see the text "Net 60 Days" inside the filter TextBox.

2. The column reorder and sorting seem to work fine, but not for paging. How do I accomplish that?

Thank you,

Sompop

This is a profile section in my web.config.
    <profile enabled="true" defaultProvider="MyProfileProvider">
      <providers>
        <add name="MyProfileProvider" connectionStringName="myConnectionString" applicationName="/" type="System.Web.Profile.SqlProfileProvider"/>
      </providers>
      <properties>
        <add name="GridAssetSettings" allowAnonymous="false" type="GridAssetSettings" serializeAs="Binary"/>  
</properties>
    </profile>

In .cs of the page where there is a RadGrid

protected override void Render(HtmlTextWriter writer)
{
  base.Render(writer);

  GridAssetSettings gas = new GridAssetSettings();
  gas.SaveGridAssetSettingsNames(RadGridSaveGridSettingsUserBase, "RadGridSaveGridSettingsUserBase");
  Context.Profile.SetPropertyValue("GridAssetSettings", gas);
}

protected void Page_Init(object sender, EventArgs e)
{
  if (Context.Profile.GetPropertyValue("GridAssetSettings") != null)
  {
    GridAssetSettings gas = (GridAssetSettings)Context.Profile.GetPropertyValue("GridAssetSettings");

    if (gas.Names.ContainsKey("RadGridSaveGridSettingsUserBase"))
      {
         GridSettings settings = new GridSettings(RadGridSaveGridSettingsUserBase);
         settings.LoadSettings(gas.Names["RadGridSaveGridSettingsUserBase"].ToString());
      }
    }
  }
}

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 24 Oct 2011, 01:43 AM
Hi Vincent,

You can use the GridSettingsPersister class as shown in this online example 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.

Regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Sompop
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or