Skip to content

Commit 07723ff

Browse files
authored
docs(grid): Improve row numbering KB
1 parent f4dffec commit 07723ff

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

knowledge-base/grid-row-numbers.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ In the general case, that logic would be done by the backend, this sample keeps
4242
FilterMode=@GridFilterMode.FilterRow Sortable="true" Pageable="true"
4343
Reorderable="true" Resizable="true" SelectionMode="@GridSelectionMode.Multiple">
4444
<GridColumns>
45-
46-
<GridColumn Field="@nameof(Employee.RowIndex)" Title="#" Width="40px" Sortable="false" Filterable="false" Groupable="false" Editable="false" />
47-
48-
<GridColumn Field=@nameof(Employee.ID) Editable="false" Filterable="false"/>
45+
<GridColumn Field="@nameof(Employee.RowIndex)" Title="#" Width="50px"
46+
Sortable="false" Filterable="false" Groupable="false" Editable="false" />
47+
<GridColumn Field=@nameof(Employee.ID) Editable="false" Filterable="false" />
4948
<GridColumn Field=@nameof(Employee.Name) Title="Name" />
5049
<GridColumn Field=@nameof(Employee.HireDate) Title="Hire Date" />
5150
</GridColumns>
@@ -62,7 +61,11 @@ In the general case, that logic would be done by the backend, this sample keeps
6261
List<Employee> iteratableData = datasourceResult.Data.Cast<Employee>().ToList();
6362
for (int i = 0; i < iteratableData.Count; i++)
6463
{
65-
iteratableData[i].RowIndex = i + 1; // we add one for human readabale 1-based index
64+
// OR Take paging into account...
65+
iteratableData[i].RowIndex = i + 1 + (args.Request.Page - 1) * args.Request.PageSize;
66+
67+
// ...OR start numbering on each page from 1.
68+
//iteratableData[i].RowIndex = i + 1; // we add one for human readabale 1-based index
6669
}
6770
datasourceResult.Data = iteratableData;
6871
// end row index setup

0 commit comments

Comments
 (0)