sortingpaginationdatagridlogic

How To Program Sorting With Paging The Right Way


I have a question about the logic behind sorting and paging.

Lets say you have a data grid with 20 pages (200 records showing 10 records per page). The grid also allows sorting.

If a user was viewing page 3 of 20 and hit the sort button on a particular field - what is the correct programmatic response to this event?

a) Should the grid sort the records only on page 3

b) Should the grid get the entire data set again and sort based on that, and then

thanks

Grant.


Solution

  • I don't think there is a correct response, but I can tell you that most websites I visit would send the user back to the first page when a new sort method is chosen. This makes sure that they actually see relevant results.

    Imagine you are browsing for computer parts. You get to the third page and realize you can't afford most of the parts anyway. So you select sort by price. You want to see the cheapest stuff at this point so if you were redirected to page 3, you might assume that is the cheapest hardware when in fact, the cheapest is on page 1.

    The user is explicitly selecting a sort method so why not show them the relevant results by starting at the first page?