This question is locked. New answers and comments are not allowed.
Hello,
My grid has a column that displays the index of rows as below. I am trying to enumerate these index numbers from 1 to n or from n to 1, according to sorting direction of column.
How can I detect the direction of applied sort, so that i can set the index on onDataBinding event and also apply ++index or --index according to sort direction? Numbers should be from 1 to n, when sorted asc; and from n to 1 when sorted desc.
Thanks,
Ilker.
My grid has a column that displays the index of rows as below. I am trying to enumerate these index numbers from 1 to n or from n to 1, according to sorting direction of column.
How can I detect the direction of applied sort, so that i can set the index on onDataBinding event and also apply ++index or --index according to sort direction? Numbers should be from 1 to n, when sorted asc; and from n to 1 when sorted desc.
<script type="text/javascript"> var index = 0; function onDataBinding(){ var grid = $("#grdInvoiceItems").data('tGrid'); index = (grid.currentPage -1) * grid.pageSize; //Sorting like 1,2,3,4.. (by ++index) index = ('@ViewBag.TotalRows'); //Sorting like 10,9,8,7.. (by --index) }</script>@{ ... columns.Bound(m => m.RecordPosition).Width(10).HtmlAttributes(new { nowrap = "nowrap" }) .ClientTemplate(@"<#= ++index #>").Title("#").Filterable(false); ... .EnableCustomBinding(true) .DataBinding(dataBinding => dataBinding.Ajax().Select("_GetInvoiceItems", (string)ViewBag.Controller)) .ClientEvents(e => e.OnDataBinding("onDataBinding")) .Sortable(s => s.OrderBy(sortOrder => sortOrder.Add(m => m.RecordPosition).Ascending()) .SortMode(GridSortMode.MultipleColumn)) .Filterable(); fl.Render(); }Thanks,
Ilker.