Sorting on only leaf task

I want to display only leaf tasks in sorted order after clicking on a column heading without any hierarchy using javascript.
I tried all possible ways but it shows hierarchy sorting of leaf tasks. Is there a solution to this problem?

Hello Kavisha,
You need to use a custom sorting function:
Then you need to attach it to the grid column header by modifying the label parameter in the column configuration:

If you don’t want to see some tasks, you can hide them with the onBeforeTaskDisplay event handler:

Here is an example of how it can be implemented:

If you need something different, please, describe your question in more detail. You can also send me a picture of how you imagine it should work.

I created object of only leaf task and I want to sort only this new object which I created for leaftask and displayed only that values which are in new object but DHTMLX gantt take gantt object with all task by default so sorting is not accorting to my expactation so is there any way that I can use my object for sorting?

Hello Kavisha,
Gantt sorts the tasks in the chart, not custom objects. To sort a custom object, you need to use the Javascript’s sort function:

If you want to sort tasks in a specific object, you need to remove the existing tasks and load the tasks from the object. Then you can sort tasks and save them in a new object with the getTaskByTime or serialize methods:
After that, you can load previous tasks.

If you want to sort only specific tasks and ignore other tasks, you will need to create a custom sorting function and pass it to the gantt.sort method:
Here is an example of how it can be implemented: