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

[Solved] Set the sort column programmatically on the grid

0 Answers 84 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.
Bhavesh
Top achievements
Rank 1
Bhavesh asked on 11 Apr 2013, 10:40 PM
I have a MVC Grid binding using a server and ajax binding and when user sort a column I save the grid's orderby value to database using a webservice call, so when use return back to the page i have to retrieve the orderby value and set it back to grid.

I tried to retrieve the orderby value to viewbag and set it to the sort.orderby as below
.Sortable(sort =>
    sort.OrderBy(
    config => config.Add(ViewBag.GridSortColumn)
    )
)

The above does not work on the server-side binding and it work partially on ajax binding i.e. it sorts by the column but only in ascending order. The example for GridSortColumn value will be like "Name-asc" or "Name-desc", both this instances it sorts by ascending order only.
Tags
Grid
Asked by
Bhavesh
Top achievements
Rank 1
Share this question
or