This question is locked. New answers and comments are not allowed.
William Brown
Top achievements
Rank 1
William Brown
asked on 03 Jun 2010, 05:04 PM
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
Thanks!
Bill
10 Answers, 1 is accepted
0
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.
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.
0
William Brown
Top achievements
Rank 1
answered on 04 Jun 2010, 09:38 PM
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?
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?
0
William Brown
Top achievements
Rank 1
answered on 04 Jun 2010, 09:45 PM
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
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
0
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.
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.
0
William Brown
Top achievements
Rank 1
answered on 09 Jun 2010, 10:16 PM
Thanks Atanas!
This is great
Bill
This is great
Bill
0
Sebastian S
Top achievements
Rank 1
answered on 23 Jun 2010, 03:47 AM
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
grid.groupBy property.
Also - is there a way to restore the orderby icons on the column?
--Sebastian
0
William Brown
Top achievements
Rank 1
answered on 02 Jul 2010, 10:28 PM
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"] %>";
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"] %>";
0
Sebastian S
Top achievements
Rank 1
answered on 04 Jul 2010, 10:24 PM
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
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
0
Pedro
Top achievements
Rank 1
answered on 13 Jul 2010, 02:20 PM
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 ?
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 ?
0
H
Top achievements
Rank 1
answered on 22 Oct 2010, 04:56 PM
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.