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

[Solved] Save Grid URL (Grid State)

2 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Joshua
Top achievements
Rank 1
Joshua asked on 29 May 2012, 03:07 PM
Hello,

My binding to the Telerik Grid is using AJAX.  What I'd like to do, however, is have a way to access the grid's current select URL (via javascript) as if it were using server binding.  That way, a user could copy the grid's 'state' (filter, sorting, page) and either navigate to it at a later time or send the URL to another user.

I know that this works.  If you navigate to the URL with the correct paremeters, such as /test?[gridID]-orderBy=[column]-desc ... etc.  It loads the grid via AJAX and performs the sorting/filtering/whatever.

All I need, is a way to obtain the grid's select URL (with all the filtering, sorting, etc) included.

Any ideas?

Thanks,
Josh

2 Answers, 1 is accepted

Sort by
0
Joshua
Top achievements
Rank 1
answered on 30 May 2012, 08:36 PM
Nevermind, I figured it out.  Below is a snippet of the JavaScript that achieves the desired result:
var grid = $('#' + gridId).data('tGrid');             
var url = grid.url('selectUrl');             
var urlFormat = url + (url.indexOf('?') >= 0 ? '&' : '?') + 'page={0}&orderBy={1}&filter={3}';             
return $.telerik.formatString(unescape(urlFormat), grid.currentPage, grid.orderBy || "~", grid.groupBy || "~", encodeURIComponent(grid.filterBy) || "~", grid.pageSize || "~");
0
Alex
Top achievements
Rank 1
answered on 19 Jul 2012, 01:34 PM
I assume that you used that script in a client event. I tried to put it in the onDataBinding function, but it didn't work.
Tags
Grid
Asked by
Joshua
Top achievements
Rank 1
Answers by
Joshua
Top achievements
Rank 1
Alex
Top achievements
Rank 1
Share this question
or