Skip to main content
All docs
V24.1

DxTreeListDataColumn.AllowSort Property

Specifies whether users can sort data by the current column.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[DefaultValue(null)]
[Parameter]
public bool? AllowSort { get; set; }

Property Value

Type Default Description
Nullable<Boolean> null

true to allow users to sort column data; otherwise, false.

Remarks

The component allows users to sort data as follows:

  • Click a column header to sort data in ascending order and clear sort criteria for all other columns. Subsequent clicks reverse the sort order. The sort glyph indicates the column’s current sort order.
  • Hold Shift and click column headers to sort data by multiple columns.
  • Hold Ctrl and click a column header to clear sorting by this column.

Users can focus a column header and press Space, Shift+Space, or Ctrl+Space to change sort settings.

Blazor TreeList Sort Data

Set the TreeList’s AllowSort property to false to prevent users from sorting TreeList data. The column’s AllowSort property allows you to specify whether users can sort TreeList data by this column. Note that the value specified at the column level overrides that of the component level.

Note

You can use the column’s SortIndex property and SortBy method to sort data in code regardless of the AllowSort property value.

The following code snippet prevents users from sorting TreeList data in the Start Date column:

@inject EmployeeTaskService EmployeeTaskService

<DxTreeList Data="TreeListData" KeyFieldName="Id" ParentKeyFieldName="ParentId">
    <Columns>
        <DxTreeListDataColumn FieldName="Name" Caption="Task" />
        <DxTreeListDataColumn FieldName="EmployeeName" />
        <DxTreeListDataColumn FieldName="StartDate" AllowSort="false"/>
        <DxTreeListDataColumn FieldName="DueDate" />
    </Columns>
</DxTreeList>

@code {
    List<EmployeeTask> TreeListData { get; set; }

    protected override void OnInitialized() {
        TreeListData = EmployeeTaskService.GenerateData();
    }
}

Run Demo: TreeList - Sort Data

For more information about data sorting in the TreeList component, refer to the following topic: Sort Data in Blazor TreeList.

Implements

See Also