views:

58

answers:

1

Hello , i am using the MvcContrib grid for an mvc application. I have set up sorting and paging , but I have to make the grid to go the first page when the user sorts the grid .

Any ideas on how doing that ?

A: 

You could append an additional parameter to the sort action which is currentPage or whatever you use in your pager to track the current page and when generating this link set the parameter value to 1. Also make sure that on the server side in the sorting action you are specifying the proper range when paging the data source (.AsPagination(1, PAGE_SIZE)).

Darin Dimitrov
How can i append some additional parameters, for current sorting ? I tried adding some hidden fields but when the users click on a column name to sort , the values didn't passed to the controller.
ad-g0
It depends how you handle the sort links. If you are using hyperlinks you will need to pass the parameters as query string when generating those links.
Darin Dimitrov
I use the links , that MvcContrib generates for sorting when adding the following at the grid: .Sort(ViewData["sort"] as GridSortOptions)
ad-g0
Any ideas on how to add the parameter with the previous sorting , so that if the sorting is different than the current i will redirect the user to page 1. PS:Maybe there are better approaches too.
ad-g0