Hi,
Is it possible to show the sort indicator on a column while allow sort is disabled on the grid?
Say for example that data is loaded from a backend API and data is sorted on a timestamp (desc) and I want to show a sort indicator on the timestamp column header while user should not be allowed to change sort order for that or any other column?
Kind regards,
Niklas
Hi Niklas,
Based on your requirement to show a sort indicator on a column header while disallowing sorting in the entire grid, you can customize the headetemplate of the specific column. This approach allows you to manually add a sort indicator even though sorting is disabled in grid.Kindly refer to the below code snippte and sample for your reference,
<SfGrid DataSource="@GridData" AllowSorting="false" Height="315"> <GridColumns> <GridColumn Field="@nameof(OrderData.OrderID)" HeaderText="Order ID" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="90"></GridColumn> <GridColumn Field="@nameof(OrderData.CustomerID)" HeaderText="Customer ID" Width="100"> <HeaderTemplate> <div style="display: flex; align-items: center;"> Customer ID <span class="e-icons e-icon-descending" style="margin-left: 20px;"></span> </div> </HeaderTemplate> </GridColumn> <GridColumn Field="@nameof(OrderData.ShipCity)" HeaderText="Ship City" Width="100"></GridColumn> <GridColumn Field="@nameof(OrderData.ShipName)" HeaderText="Ship Name" Width="120"></GridColumn> </GridColumns> </SfGrid> |
Note: Clicking on the header icon won’t change the sort order.
Sample: https://blazorplayground.syncfusion.com/embed/VNrfZcBUKwRVtNrS?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5
Reference: https://blazor.syncfusion.com/documentation/datagrid/column-headers#header-template
Regards,
Prathap Senthil
Thanks, that did the trick :)
//Niklas
Thanks for the update,
We are happy to hear that the provided solution was helpful. We are closing the thread now.