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

[Solved] Restoring the grid settings...

0 Answers 42 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.
Jason
Top achievements
Rank 1
Jason asked on 19 Oct 2011, 03:38 PM
Hey Folks,

http://www.telerik.com/community/code-library/aspnet-mvc/grid/preserve-grid-state-between-pages.aspx

Good demo that.  I used it to get around a problem with dates (which I posted in another part of the forum).  My ActionMethod now puts the GridRouteValues (which I guess is parsing the request string?) into the ViewBag and voilĂ , the grid remembers its filter, sorting, etc.

There's still an issue sorting though, which appears just to alter the href of the page and pass along all the parameters... but not all, depending on context.  The first binding will occur with a date filter which is a separate form on the page.  The user alters the date (via a datepicker) and that then submits the form (along with 'GridRouteValues' hidden in the form) so the grid state is maintained.  So far so good, a filter (for example) comes back applied correctly.  Altering a filter in the grid will then prompt the grid to 'submit' the whole thing and it still maintains its state (both filters applied).  The problem arises when the date form is submitted and the page/filter is restored but then the user sorts on a column header.  This just appears send the request back to the server without the entire grid state!  My first example (the user filters something, submits a date then applies another filter) looks like this:

    ~/orders?receivedSince=09/01/2011 14:29:00&Grid-page=1&Grid-orderBy=Registration-desc&Grid-groupBy=~&Grid-filter=Registration~startswith~'RI'~and~Type~startswith~'O'&Grid-size=20

Second example is this (user filters something, submits a date and then clicks a column heading to sort on 'DateTime'):

    ~/orders?receivedSince=09%2F01%2F2011%2014%3A29%3A00&p=Inbox&Grid-orderBy=DateTime-asc

Where's the rest of the query string (i.e. Grid-filter, etc...)?  It's like some bit of code has read the state correctly but the link for column headings does not?

Help please!

Regards,
Jason
Tags
Grid
Asked by
Jason
Top achievements
Rank 1
Share this question
or