Sorting in ASP.NET Core Gantt Chart Component
18 Nov 20182 minutes to read
Sorting enables you to sort data in the ascending or descending order. To sort a column, click the column header.
To sort multiple columns, press and hold the CTRL key and click the column header. You can clear sorting of any one of the multi-sorted columns by pressing and holding the SHIFT key and clicking the specific column header.
To enable sorting in the Gantt control, set the AllowSorting property to true. Sorting options can be configured through the SortSettings property.
The following screenshot shows the output of multicolumn sorting in Gantt control.

NOTE
- Gantt columns are sorted in the ascending order. If you click the already sorted column, the sort direction toggles.
* To disable sorting for a particular column, set theColumns.AllowSortingproperty to false.
Sorting column on Gantt initialization
The Gantt control can be rendered with sorted columns initially, and this can be achieved by using the SortSettings property. You can add columns that are sorted initially in the SortSettings.Columns collection defined with Field and Direction properties. The following code example shows how to add the sorted column to Gantt initialization.
Sorting column dynamically
Columns in the Gantt control can be sorted dynamically using the sortColumn method. The following code example demonstrates how to invoke the sortColumn method by clicking the custom button.

Before Sorting

After Sorting
Clear all the sorted columns dynamically
In the Gantt control, you can clear all the sorted columns and return to previous position using the clearSorting public method. The following code snippet shows how to clear all the sorted columns by clicking the custom button.
Sorting events
During the sort action, the Gantt control triggers two events. The ActionBegin event triggers before the sort action starts, and the ActionComplete event triggers after the sort action is completed.
NOTE
The
args.requestTypeis the current action name. For example, for sorting theargs.requestType, value is sorting.
Sorting custom columns
In Gantt, you can sort custom columns of different types like string, numeric, etc., By adding the custom column in the column collection, you can perform initial sort using the sortSettings or you can also sort the column dynamically by a button click.
The following code snippets explains how to achieve this.
Touch interaction
To perform tap action on a column header, trigger sorting operation to the selected column. A popup is displayed for multi-column sorting. To sort multiple columns, tap the popup, and then tap the desired column headers.
The following screenshot shows Gantt touch sorting,
