From 0416ba4d6d5c51d7fe4581d429c30c18f0fb5ad1 Mon Sep 17 00:00:00 2001
From: ALMMa
It's a no brainer too.
What about ordering?
+What about filtering/ordering?
- To help you out, get only the columns which were ordered on client-side with IDataTablesRequest.GetSortedColumns()
.
- Than, iterate through then and use Column.SortDirection
to sort your dataset.
+ To help you out, there are two methods on ColumnCollection
to help you out:
+ IDataTablesRequest.Columns.GetSortedColumns()
will return an ordered enumeration of sorted columns.
+ IDataTablesRequest.Columns.GetFilteredColumns()
will return an enumeration of columns which were actually filtered on client-side.
Sample:
```C# +// Apply filter to your dataset based only on the columns that actually have a search value. var filteredColumns = requestParameters.Columns.GetFilteredColumns(); foreach(var column in filteredColumns) Filter(column.Data, column.Search.Value, column.Search.IsRegexValue); + +// Set your dataset on the same order as requested from client-side either directly on your SQL code or easily +// into any type or enumeration. var sortedColumns = requestParameters.Columns.GetSortedColumns(); var isSorted = false; foreach(var column in sortedColumns) @@ -63,4 +68,9 @@ foreach(var column in sortedColumns) if (!isSorted) { Sort(column.Data, column.SortDirection); isSorted = true; } else { SortAgain(column.Data, column.SortDirection); } } -``` \ No newline at end of file +``` + ++ If you do find any issues, please, submit then and I'll fix it ASAP. +
\ No newline at end of file