GanttChart Sorting


Smart.GanttChart component uses a Table component which allows to sort the tasks/resources based on a column. The sortMode property determines the sorting mode of the element. Tasks/Resources can be sorted by setting the sortMode property to either one (allows to sort by a single column), many (allows to sort by multiple columns) or none ( disabled sorting ). By default sorting is disabled.

Once the sortMode property is configured to allow sorting, the user has two options to apply sorting to the tasks/resources:

  • Click on a Table column header inside the GanttChart.
  • Call the API's sort method by passing an array of strings which correspond to taskColumn/resourceColumns column values or objects that contain the same with an additional sortOrder attribute that allows to preset the sorting order ('asc' - ascending order or 'desc' - descending order). For example:
    const ganttChart = document.querySelector('smart-gantt-chart');
    ganttChart.sortMode = 'one';                            
     { value: 'duration', sortOrder: 'asc', type: 'task' }, 
     { value: 'progress', sortOrder: 'asc', type: 'resource' }

    As a result the Tasks will be sorted by their duration in ascending order and the Resources will be sorted by progress in ascending order as well.

The timeline is updated as soon as a Table columns is sorted.

Sorting can be cleared at any time via the clearSort method.