Saving / Restoring RadGrid Layout

13 posts, 0 answers
  1. RD
    RD avatar
    12 posts
    Member since:
    Dec 2009

    Posted 28 Dec 2009 Link to this post

    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
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 Dec 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. RD
    RD avatar
    12 posts
    Member since:
    Dec 2009

    Posted 12 Jan 2010 Link to this post

    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
  5. Felipe
    Felipe avatar
    2 posts
    Member since:
    Apr 2011

    Posted 05 May 2011 Link to this post

    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.
  6. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 06 May 2011 Link to this post

    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.

  7. Felipe
    Felipe avatar
    2 posts
    Member since:
    Apr 2011

    Posted 06 May 2011 Link to this post

    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...

  8. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 09 May 2011 Link to this post

    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.

  9. Kamal
    Kamal avatar
    34 posts
    Member since:
    Jan 2013

    Posted 15 May 2015 Link to this post

    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">

     

  10. Kamal
    Kamal avatar
    34 posts
    Member since:
    Jan 2013

    Posted 17 May 2015 Link to this post

    Please team can someone advise me on this.
  11. Kostadin
    Admin
    Kostadin avatar
    1708 posts

    Posted 20 May 2015 Link to this post

    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
  12. Kamal
    Kamal avatar
    34 posts
    Member since:
    Jan 2013

    Posted 20 May 2015 Link to this post

    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.

     

  13. Kamal
    Kamal avatar
    34 posts
    Member since:
    Jan 2013

    Posted 21 May 2015 Link to this post

    Hello Team,

    Please can you suggest something.

    Thanks

    Kamal

  14. Kostadin
    Admin
    Kostadin avatar
    1708 posts

    Posted 25 May 2015 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017