BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
@{
List<object> cols = new List<object>();
cols.Add(new { field = "CustomerID", direction = "Ascending" }); //Column to apply initial sort
}
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.DataSource).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("CustomerID").HeaderText("Customer Name").SortComparer("sortComparer").Width("150").Add();
...
}).AllowPaging().AllowSorting(true).SortSettings(sort => sort.Columns(cols)).AllowGrouping(true).Render()
<script>
function sortComparer(reference, comparer) { //Here you can define your custom sort function
return -1; //return -1 will restrict the sort
};
</script>
|
public override object Read(DataManagerRequest dm, string key = null)
{
...
if (dm.Sorted != null && dm.Sorted.Count > 0 && dm.Sorted[0].Name != "CustomerID")
{
// Sorting
DataSource = DataOperations.PerformSorting(DataSource, dm.Sorted);
}
...
return dm.RequiresCounts ? new DataResult() { Result = DataSource, Count = count } : (object)DataSource;
}
|