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

GridSettingsPersister not working second time

3 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dharmesh
Top achievements
Rank 1
Dharmesh asked on 23 May 2011, 09:24 AM
Hello All,

I have drop down box which consist of user saved views using GridSettingsPersister class.

Now my issue is that when first time user comes to page and select its saved view its load correctly.
But after loading first view when tries to change another view from drop down its get failed.
After doing some debugging I found that inside GridSettingsPersister -> Grid_ColumnsCreated Event settings which I supply loads correctly but when grid seen on page its just have first time loaded settings however data is changing into grid.

Can anyone suggest me what I am doing wrong?

Regards,

Dharmesh

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 27 May 2011, 09:55 AM
Hello Dharmesh,

Please try to modify the GridSettingPersister class this way:
protected virtual void LoadColumnSettings()
{
    List<ColumnSettings> settings = new List<ColumnSettings>(Settings.ColumnSettings);
    settings.AddRange(Settings.AutoGeneratedColumnSettings);
    foreach (ColumnSettings setting in settings)
    {
        GridColumn column = Grid.MasterTableView.GetColumnSafe(setting.UniqueName);
        if (column != null)
            SetColumnSettings(ref column, setting);
    }
}

Let me know whether this helps.

Kind regards,
Daniel
the Telerik team

Browse the vast support resources we have to jump start 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
Kyle
Top achievements
Rank 1
answered on 06 Mar 2012, 05:41 PM
Thanks Daniel!  I was having a similar issue and this fixed it for me.  My issue was that it was only updating the CurrentFilterValue or the CurrentFilterFunction on each column after the first load.  Then if I changed the GridSettingsPersister to another value, the CurrentFilterValue and the CurrentFilterFunction would not update.  I also had to add the following code for when I wanted to remove them on my own:

foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)
        {
            if (col.SupportsFiltering())
            {
                col.CurrentFilterValue = string.Empty;
                col.CurrentFilterFunction = GridKnownFunction.NoFilter;
            }
        }

Are there any plans to have the class updated in a future release so others don't run into this?  I have the Q1 2012 release and pulled the GridSettingsPersister.cs out of the Live Demos\App_Code\Grid folder.

Also, as a hint to anyone else who has this issue, the main piece is changing the foreach loop to use "settings" instead of "Settings.ColumnSettings" (making sure that you don't just delete the ".ColumnSettings" but actually changing it to "settings" since the capital "S" makes it use the Settings object instead of the List<ColumnSettings> variable).  I missed that mundane detail the first time trying to fix this.
0
Daniel
Telerik team
answered on 09 Mar 2012, 03:56 PM
Hi Kyle,

Thanks for the appointment. We will update the code for the next minor release or RadControls for ASP.NET AJAX.

Regards,
Daniel
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
Dharmesh
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Kyle
Top achievements
Rank 1
Share this question
or