Grid sorting


Person column:
Food column:

GridDemo/SortingContent.cshtml
@model AweCoreDemo.ViewModels.Input.GridDemoSortingCfgInput

@(Html.Awe().Grid("SortingGrid")
.Columns(
new Column{Bind = "Id", Width = 75},
new Column{Bind = "Person", Sortable = Model.PersonSortable, SortRank = Model.PersonRank, Sort = Model.PersonSort},
new Column{Bind = "Food.Name", Sortable = Model.FoodSortable, SortRank = Model.FoodRank, Sort = Model.FoodSort},
new Column{Bind = "Date", Width = 150}, new Column{Bind = "Price", Width = 80, ClientFormat = ".(Price)£"},
new Column{Bind = "Location"})
.Height(350)
.SingleColumnSort(Model.SingleColumnSort)
.Sortable(Model.Sortable)
.Url(Url.Action("GetItems","LunchGrid")))

Sorting can be enabled or disabled for the whole grid by using the .Sortable(bool) and can be set for each column by setting the Column.Sortable

  • SingleColumnSort - enables sorting by one column at a time
  • Column.Sort - initial sorting for this column (None | Asc | Desc)
  • Column.SortRank - initial sort rank for this column



Comments