DataGrid OrderIndex does not work #387

Closed
opened 2026-01-29 17:36:28 +00:00 by claunia · 2 comments
Owner

Originally created by @bhaeussermann on GitHub (Apr 27, 2022).

Setting the RadzenDataGridColumn.OrderIndex property in my page's Razor template does not have an effect. Here's my code sample:

<RadzenDataGrid TItem="Employee" Data="@EmployeesList" AllowSorting="true">
    <Columns>
        <RadzenDataGridColumn Title="Last Name" TItem="Employee" Property="LastName" OrderIndex="1" />
        <RadzenDataGridColumn Title="First Name" TItem="Employee" Property="FirstName" />
        <RadzenDataGridColumn Title="Title" TItem="Employee" Property="Title" />
    </Columns>
</RadzenDataGrid>

When the data is set, the LastName column is not ordered. Even the official DataGrid column reorder example page sets this property and it doesn't take effect.

To Reproduce
Heck, visit the official DataGrid column reorder page. It sets OrderIndex to the LastName and FirstName columns, but the columns are not being ordered! Am I missing something?

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Firefox 99.0.1
Originally created by @bhaeussermann on GitHub (Apr 27, 2022). Setting the `RadzenDataGridColumn.OrderIndex` property in my page's Razor template does not have an effect. Here's my code sample: ``` <RadzenDataGrid TItem="Employee" Data="@EmployeesList" AllowSorting="true"> <Columns> <RadzenDataGridColumn Title="Last Name" TItem="Employee" Property="LastName" OrderIndex="1" /> <RadzenDataGridColumn Title="First Name" TItem="Employee" Property="FirstName" /> <RadzenDataGridColumn Title="Title" TItem="Employee" Property="Title" /> </Columns> </RadzenDataGrid> ``` When the data is set, the LastName column is not ordered. Even the official [DataGrid column reorder](https://blazor.radzen.com/datagrid-column-reorder) example page sets this property and it doesn't take effect. **To Reproduce** Heck, visit the [official DataGrid column reorder](https://blazor.radzen.com/datagrid-column-reorder) page. It sets `OrderIndex` to the LastName and FirstName columns, but the columns are not being ordered! Am I missing something? **Desktop (please complete the following information):** - OS: MacOS - Browser: Firefox 99.0.1
Author
Owner

@enchev commented on GitHub (Apr 28, 2022):

You need to set OrderIndex to other columns as well otherwise the grid will keep the declared columns order.

@enchev commented on GitHub (Apr 28, 2022): You need to set OrderIndex to other columns as well otherwise the grid will keep the declared columns order.
Author
Owner

@bhaeussermann commented on GitHub (Apr 28, 2022):

Oooh, I see I misinterpreted the meaning of the OrderIndex property. I was under the impression that it affects the ordering of the rows (sort by last name, then by first name, etc.). I now understand that it actually determines the order in which the columns are displayed from left to right.

There doesn't seem to be a way to set the DataGrid to be initially sorted based on one specified column.

@bhaeussermann commented on GitHub (Apr 28, 2022): Oooh, I see I misinterpreted the meaning of the `OrderIndex` property. I was under the impression that it affects the ordering of the rows (sort by last name, then by first name, etc.). I now understand that it actually determines the order in which the columns are displayed from left to right. There doesn't seem to be a way to set the DataGrid to be initially sorted based on one specified column.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#387