Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Grid > Is there a way to save grid stage?

Not answered Is there a way to save grid stage?

Feed from this thread
  • William Brown avatar

    Posted on Jun 3, 2010 (permalink)

    I want to save a grids settings, including set filters, groups, column widths, etc. after a user changes any of these. Is there a way to do this with the MVC Grid?  I've seen other posts for the saving state for non mvc grids such as: http://blogs.telerik.com/vladimirenchev/posts/09-04-03/how_to_save_and_load_settings_with_radgridview_for_wpf.aspx

    Thanks!

    Bill

  • Atanas Korchev Atanas Korchev admin's avatar

    Posted on Jun 4, 2010 (permalink)

    Hi William Brown,

    The grid maintains the filter and group expressions internally - you can perhaps use them:

    var groupExpression = grid.groupBy;
    var filterExpression = grid.filterBy;

    The grid however does not know the width of its columns. By the way how is the user resizing the columns?

    Regards,
    Atanas Korchev
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.

  • William Brown avatar

    Posted on Jun 4, 2010 (permalink)

    Hi Atanas,

    Ha!  I'm used to the aspnet ajax grid.  The user isn't resizing columns in our MVC grids.  Would love to be able to in MVC.  If I saved the grid.groupBy and grid.filterBy for the user, would I then just apply those when the grid is loaded for that user and that's it? 

  • William Brown avatar

    Posted on Jun 4, 2010 (permalink)

    Hello Atanas,

    To get the grid.groupBy, how and where do I access that with JQuery and how do I know the user changed it?

    Thanks,

    Bill

  • Atanas Korchev Atanas Korchev admin's avatar

    Posted on Jun 7, 2010 (permalink)

    Hello William Brown,

    I prepared a sample project showing how to store and restore the grid state.

    Regards,
    Atanas Korchev
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
    Attached files

  • William Brown avatar

    Posted on Jun 9, 2010 (permalink)

    Thanks Atanas!

    This is great

    Bill

  • Sebastian S avatar

    Posted on Jun 22, 2010 (permalink)

    I have tried executing the example code. It seems to break when trying to restore the
    grid.groupBy property.

    Also - is there a way to restore the orderby icons on the column?

    --Sebastian

  • William Brown avatar

    Posted on Jul 2, 2010 (permalink)

    Hi Sebastian,
     
    Atanas posted this fix for one of our engineers (see below).  I don't know if you can save sort orders. You may want to post a new post so it'll get picked up?

    Bill
    ------------------

    Try this:

    function onLoad() {
                //restore the grid state (if any)
                
                <% if (ViewData["currentPage"] != null) { %>
                
                setTimeout(function() {
                    var grid = $('#Grid').data('tGrid');
                    grid.currentPage = <%= ViewData["currentPage"] %>;
                    grid.orderBy = '<%= ViewData["orderBy"] %>';
                    grid.filterBy = '<%= ViewData["filterBy "] %>';
                    grid.groupBy = '<%= ViewData["groupBy"] %>';
                   
                    grid.groups = $.map(grid.groupBy.split('~'), function(item) {
                        var nameAndOrder = item.split('-');
                        return {member:nameAndOrder[0], order:nameAndOrder[1], title:nameAndOrder[0]};
                    });
                    
                    //refresh the grid
                    grid.ajaxRequest();
                }, 100);
                
                <% } %>
            }

    AND USE DOUBLE QUOTES to ACCESS view data:

    grid.orderBy = "<%= ViewData["orderBy"] %>";
    grid.filterBy ="<%= ViewData["filterBy"] %>";
    grid.groupBy = "<%= ViewData["groupBy"] %>";

  • Sebastian S avatar

    Posted on Jul 4, 2010 (permalink)

    Thanks William,

    Will try that fix on the grouping.
    The sort order seems to work fine as is (and the icon is restored if the latest service pack is applied).

    Cheers,
    Sebastian

  • Pedro avatar

    Posted on Jul 13, 2010 (permalink)

    Hello,

    The solution:

                    grid.groups = $.map(grid.groupBy.split('~'), function(item) {
                        var nameAndOrder = item.split('-');
                        return {member:nameAndOrder[0], order:nameAndOrder[1], title:nameAndOrder[0]};
                    });


    from William Brown worked, although the icon on the header of the grid mentioning the groups disappear.

    Is there a way to keep the icon of the groups after refreshing ?
    Also the text on the search filters disapears after the refresh, is there a way to keep the text there ?

  • H avatar

    Posted on Oct 22, 2010 (permalink)

    Did anyone find the solution to this?  We have the same issue where the grouping heading/icon is lost after the refresh, which also means the grouping can't be removed.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Grid > Is there a way to save grid stage?
Related resources for "Is there a way to save grid stage?"

ASP.NET MVC Grid Features  |  Documentation  |  Demos  |  Telerik TV ]