Sorting multiple independent grids on one page

Jun 16, 2014 at 8:45 PM

I have multiple independent grids on one page with sorting. When I sort by column on one grid, it will reset sorting on the others grids.
The documentation related to multiple grid will not help me, because it's related to multiple dependent grids (the same model for grid).

Is there a way how to bind URI parameters grid-column and grid-dir to the grid name or how to store sorting parameters for grid ?
Or could you help me, how to solve this problem ?

Paging works perfectly based on documentation.

Thank you.

Best regards,
Jun 22, 2014 at 7:52 AM

You need to override Settings.SortSettings of Grid<T> class:

Create a custom derrived Grid class:
    public class MyGrid : Grid<Order>
        public MyGrid (IQueryable<Order> items)
            : base(items)
            var querySettings = (QueryStringSortSettings)Settings.SortSettings;

            querySettings.ColumnQueryParameterName = "mygrid-column";
            querySettings.DirectionQueryParameterName = "mygrid-dir";

Then you can render this Grid as IEnumerable collection:
May 29, 2015 at 9:25 PM
Edited May 29, 2015 at 9:27 PM
Hello, I tried overriding the grid as you stated above, but when I go to reference it in the View, I don't get the Grid showing up after I type @Html.Grid(Model.
<p> Any reasons why this would be? </p> Thanks