Tagged: datagrid sort column, datagrid sort index
I want to set the sort indexes of columns programmatically, but I could not found a property something like “SortIndex”
In the GridColumn properties I could only found “SortOrder”. Is there a way to achieve that?
Thanks in advance.
The Grid’s SortBy method can be used to apply sorting to a column using the Grid API. SortIndex Column property is not available.
Smart UI Team
I could’t find a method “SortBy” (we are in Blazor)?
I could use an event callback “Sort” e.g.
private async Task Sort(Event ev)
GridSortEventDetail sortEventDetail = ev[“Detail”];
var sortIndex = sortEventDetail.Columns[“sortIndex”];
But the sortIndex is always “0”, but I know it must be somewhere, how does the grid know the sort index (sort indexes are shown in the columns 😉
The problem is when the user does a multiple sort and I want to save these settings there is no way to set the sort indexes correctly again.
For example we have three columns
ID [SortOrder DESC, SortIndex = 2] Name [SortOrder ASC, SortIndex = 1] Address [SortOrder ASC, SortIndex =3]
I want to set the colums array programmatically when the user chooses a specific setting. I can reproduce all sort orders for the columns but not the sort indexes
GridColumn newColumn = new GridColumn()
Label = …..,
SortOrder = GridColumnSortOrder.Asc,
SortIndex = …. <= I need this
The grid internally has a sort index, but there is no public API to retrieve it. This is something which we will add in the next version of the Blazor Grid as well as the missing SortBy method for it.