Is there a possibility to display a row number for each row in the datagrid, which isn't bound to the index of the property? When the number is bound to the index like this, its changing when filters are applied or data is sorted. I need a number which is not dependent on the data.
The index of the item of the collection is exactly what you are looking for since it will always start from 0 doesn’t matter filtering and sorting.
please tell me how to do it right. the numbers in the first colums are always mixed up as shown in the picture above as soon as I filter or sort.
my code at the moment:
<RadzenDataGrid @ref="@DataGrid" Data="@ListOfTubes" TItem="Tube" AllowFiltering="true" PageSize="50" AllowPaging="true" AllowSorting="true" FilterMode="FilterMode.Advanced" AllowColumnResize="true" FilterPopupRenderMode="PopupRenderMode.OnDemand"> <Columns> <RadzenDataGridColumn Width="50px" TItem="Tube" Title="#" Filterable="false" Sortable="false" TextAlign="TextAlign.Center"> <Template Context="data"> @(ListOfTubes.IndexOf(data) + 1) </Template> </RadzenDataGridColumn> ... </Columns> </RadzenDataGrid>
You can use @DataGrid.View as collection.
thanks a lot for the fast help!
got it work with
@(DataGrid.View.ToList().IndexOf(data) + 1)
I’ve updated this demo with more efficient approach to get the current row index: