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

Saving / Restoring RadGrid Layout

13 Answers 543 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RD
Top achievements
Rank 2
RD asked on 28 Dec 2009, 09:53 PM
Using the Q3 version of the ASP.NET/AJAX RadControl Suite, is there a built-in way to save / restore the current layout (ie: filtering, sorting, column order, visible columns, etc) of the grid?

ie:  Similar to what DevExpress provides:  http://www.devexpress.com/Help/?document=ASPxGridView/CustomDocument4342.htm&levelup=true

I found a code sample on your help site which seems to provide a sample piece of code for this (http://www.telerik.com/help/aspnet-ajax/grdsavingsettingsonperuserbasis.html) but the code does not compile.  (Haven't really dug into why...)

Thanks,

Roy

13 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Dec 2009, 05:26 AM
Hello Roy,

Did you happen to take a look at the following code library? If not, try downloading the sample application in the following code library which demonstrates on saving grid settings:
Storing Multiple Grid settings in Database via Profile

Hope this helps..
Princy.
0
RD
Top achievements
Rank 2
answered on 13 Jan 2010, 02:49 AM
Hi Princy,

Thanks for the feedback.

This example *almost* works.  It correctly captures (and re-applies) sorting, filtering, etc...However the one thing that it doesn't do is re-display the filter criteria when AllowFilteringByColumn="True"

ie: 
1. The user manually enters a filter criteria with the auto-filter row (ie: Name column STARTSWITH "A"). 
2. The grid is correctly filtered
3. They navigate to another page (and I use the GridSettings helper to persist the layout)
4. They navigate back to the page with the grid (and I use the GridSettings helper to re-apply the layout)

At this point, the grid is still correctly filtered, but all the auto-filter text boxes are blank, making it confusing for the user as there is no indication that a filter is in place.

Any suggestions?  I notice this sample is based on an older version of the RadGrid - is there a more up to date sample?

Thanks,

Roy
0
Felipe
Top achievements
Rank 1
answered on 05 May 2011, 03:58 PM
This is such a terrible thing! We have both Telerik's and DevExpress's suites and I was voted out when our team's architect vouched for Telerik's superiority in the ASP.NET domain over DevExpress for developing our dashboard infrastructure (using RadDockLayout, RadDocks, etc.) Now that we must persist the state of the docks and the dashboardlets I discover that the RadGrid simply does not have a SaveLayout method, and the current (and not at all concise) sample code for doing just that is out-dated!!! I've a deadline for tomorrow and I've already put into place all the dashboardlet persistence infrastructure and left the grid's and control-specific layout serialization for later because SURELY something like that wouldn't be missing in a top-notch component suite like Telerik's. My bad, I know, I should have known better.
0
Veli
Telerik team
answered on 06 May 2011, 09:26 AM
Have you seen the RadGrid Persisting Settings on a Per-User Basis demo. It demonstrates the usage of a small GridSettingsPersister class to save and load grid settings. It allows you to persist, sorting, grouping, filtering and paging settings, as well as column width, order and visibility. It can serialize your persisted settings using binary serialization and return it as a string for easy database storage.

Veli
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
Felipe
Top achievements
Rank 1
answered on 06 May 2011, 10:19 PM
I'm actually (trying out) this code. One thing that strikes me is that there are way too many streams not being correctly released as soon as possible. I've change a lot of code like this:

        public override string ToString()
        {
            LosFormatter formatter = new LosFormatter();
            StringWriter writer = new StringWriter();
            formatter.Serialize(writer, this);

            return writer.ToString();
        }

To this:

        public override string ToString()
        {
            LosFormatter formatter = new LosFormatter();
            using (StringWriter writer = new StringWriter())
            {
                formatter.Serialize(writer, this);
                return writer.ToString();
            }
        }

Apart from that, so far so good...

0
Veli
Telerik team
answered on 09 May 2011, 05:37 PM
The GridSettingsPersister from the RadGrid demo uses 2 streams - MemoryStream and StringWriter. While disposing streams after use is generally a good practice, neither of those 2 streams hold references to shared resources. The StringWriter has an empty Dispose method, while the MemoryStream only notifies it is being closed in its Dispose method(in the context of multi-threaded environments, this indicates a thread waiting to get a lock on the memory stream can now proceed). Still, your notice is most certainly correct and we will change the source code of the demo to reflect that in an effort to defend good coding practices.

Cheers,
Veli
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
Kamal
Top achievements
Rank 1
answered on 15 May 2015, 04:52 PM

Is there a way or a simple attribute in the RadGrid to turn on/off saving (in the session/cookies) all the customizations(sort order/column, page no, filter, reorder, resize) instead of a control trigger saving explicitly. It would be a great thing to have. May be like AutoSaveGridSettings="True" in the below:

 

<telerik:RadGrid ID="rgUserGroups" runat="server" AutoSaveGridSettings="True" AllowPaging="True" AllowSorting="True"
                                AutoGenerateColumns="False" OnNeedDataSource="rgUserGroups_NeedDataSource" 

                                AllowFilteringByColumn="true" Skin="Silk"  PageSize="10" HeaderStyle-Font-Bold="true"
                                AlternatingItemStyle-BackColor="#f0f0f0" ClientSettings-Resizing-ShowRowIndicatorColumn="false">

 

0
Kamal
Top achievements
Rank 1
answered on 17 May 2015, 04:28 PM
Please team can someone advise me on this.
0
Kostadin
Telerik team
answered on 20 May 2015, 07:16 AM
Hi Kamal,

If you are using RadPersistenceManager control you can easily save the grid settings by calling SaveState method. Identically you can load the state any time by calling LoadState method. You can call those method on each operation or only when requires the state to be saved/loaded.

Regards,
Kostadin
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Kamal
Top achievements
Rank 1
answered on 20 May 2015, 05:44 PM

Thanks Kostadin, I understand that. Though what I need would be a setting/attribute that simply turns on/off saving grid settings. Means I do not want to call SaveState and LoadState methods. These operations (sort/page change/filter columns/rearrange columns/resize columns)  I do in the grid on the page it should remember that (may be in session or cookies) and when I revisited the page it should load that state (if there is any customization).

With that setting/attribute set to "On", Saving and Loading happens implicitly instead of explicit call to any such methods.

I hope this scenario is clear. I'm not sure if this impractical.

 

0
Kamal
Top achievements
Rank 1
answered on 21 May 2015, 02:36 PM

Hello Team,

Please can you suggest something.

Thanks

Kamal

0
Kostadin
Telerik team
answered on 25 May 2015, 11:26 AM
Hello Kamal,

I am afraid that this functionality will not be included in the grid. Nevertheless you can create a custom control which inherits RadGrid and add such property. You should note that you can hook OnItemCommand and save the state there in case you need to save it after each operation.

Regards,
Kostadin
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
DogBizPro
Top achievements
Rank 1
answered on 31 Jan 2018, 08:51 PM
I do not see that persisting the column order per user.
Tags
Grid
Asked by
RD
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
RD
Top achievements
Rank 2
Felipe
Top achievements
Rank 1
Veli
Telerik team
Kamal
Top achievements
Rank 1
Kostadin
Telerik team
DogBizPro
Top achievements
Rank 1
Share this question
or