'How can I do sorting on multiple columns in WebGrid?

I am using WebGrid in my ASP.NET MVC 3 (C#) application. I want to do sorting on multiple columns(like we can do in tablesorter).

Is it possible in WebGrid? If so, how can I do it?



Solution 1:[1]

The WebGrid Helper provides sorting by default.

So, you'd get sorting and paging by default when you write a simple instantiation like below:

var myGrid = new WebGrid(Model);
myGrid.GetHtml();

Quoted from a dead link:

Out of the box, the WebGrid provides these functions by doing Get requests and passing in a few values over the query string. The WebGrid will see these values in the new request, and adjust the output accordingly. This means that the WebGrid expects the entire set of data in each view in order to generate the paging properly.

This means that you would have performance issues for larger datasets as you would need to pull all of it into memory at once for the Helper to compute paging and sorting metrics correctly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1