New to Kendo UI for Angular? Start a free 30-day trial
Angular Grid Sorting Basics
The sorting functionality enables you to arrange the data by single or multiple fields in ascending or descending order.
You can enable the sorting feature by using two methods:
- The Data-Binding Directive—Allows you to implement sorting (or other data operations) with less code.
- Manual Sorting—Provides more control when implementing the sorting feature.
Using the Data-Binding Directive
When you use the built-in DataBindingDirective
, the Grid performs the sorting automatically for you. To enable the sorting when the kendoGridBinding
directive is applied:
- Set the
sortable
option of the Grid. - (Optional) Set the
sort
property to a collection ofSortDescriptor
objects. This allows you to sort the data by specific criteria during the initialization of the Grid.
html
<kendo-grid
[kendoGridBinding]="gridData"
[sortable]="true">
<kendo-grid-column field="ProductID"></kendo-grid-column>
</kendo-grid>
Further details on how the data binding directive works under the hood are available in the data operations with the built-in directive documentation section.
The following example demonstrates the Grid sorting functionality when the kendoGridBinding
directive is applied.
Change Theme
Theme
Loading ...