sort

sorts tasks in the grid

void sort(string|function field, [boolean desc,string|number parent,boolean silent] );
fieldstring|functionthe name of the column that the grid will be sorted by or a custom sorting function
descbooleanspecifies the sorting direction: true - descending sort and false - ascending
sort. By default, false
parentstring|numberthe id of the parent task. Specify the parameter if you want to sort tasks only in the branch of the specified parent.
silentbooleanspecifies whether rendering should be invoked after reordering items

Example

<input type='button'  value='Sort by task name' onclick='sortByName()'>
<script>
    var n_direction = false;
    function sortByName(){
        if (n_direction){
            gantt.sort("text",false);
        } else {
            gantt.sort("text",true);
        }
        n_direction = !n_direction;
    };
    gantt.init("gantt_here");
</script>

Related samples

Details

The parent parameter is ignored when applying a custom function for sorting. Check the example.

See also
Back to top