Gantt Chart can be sorted by columns by clicking on the header of the desired column. The first click on the header will sort the Tasks in 'ascending' order. Second click will sort them in 'descending' and the third will remove the sorting.
JavaScript jqxGantt with sorting.
A live JavaScript/jQuery example of jqxGantt, the jQWidgets Gantt component, with its complete source code below. It is one of 15 jqxGantt demos for jQuery.
source property – Determines the tasks that will be loaded inside the Timeline.dateEnd property – Determines a specific end date for the Timeline.dateStart property – Determines a specific starting date for the Timeline.durationUnit property – Determines in what unit is task duration property measured.resources property – A getter that returns a flat structure as an array of all resources inside the element.resourceColumns property – Determines the columns that will be visible in the Resource Tree.sortMode property – Determines whether the GanttChart can be sorted by one, more then one or no columns.tasks property – A getter that returns a flat structure as an array of all tasks inside the element.taskColumns property – Determines the columns that will be visible in the Task Tree.treeSize property – Determines the size(width) of the task table.To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $.
The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxgantt.js, jqxgantt.api.js.
It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers).
window.onload = () => {
const gantt = new jqxGantt("#gantt", {
sortMode: 'one',
treeSize: '30%',
durationUnit: 'hour',
taskColumns: [
{
label: 'Tasks',
value: 'label',
sort: 'asc',
size: '60%'
},
{
label: 'Duration (hours)',
value: 'duration',
formatFunction: (date) => parseInt(date)
}
],
resourceColumns: [
{
label: 'Tasks',
value: 'label',
sort: 'asc',
size: '60%'
},
{
label: 'Work Time (hours)',
value: 'workload',
size: '20%'
},
{
label: 'Progress',
value: 'progress'
}
],
source: [
{
label: 'Project A',
dateStart: '2026-01-06',
dateEnd: '2026-03-06',
type: 'project',
expanded: true,
synchronized: true,
tasks: [
{
label: 'Task Z',
dateStart: '2026-02-25',
duration: 1500,
progress: 30,
connections: [{ target: 2, type: 1 }],
resources: [{ id: 'resource1', label: 'Resource 1' }, { id: 'resource2', label: 'Resource 2' }]
},
{
label: 'Task Y',
dateStart: '2026-04-07',
duration: 1500
}
]
},
{
label: 'Task C',
dateStart: '2026-05-13',
duration: 1000,
progress: 45,
connections: [{ target: 4, type: 1 }],
resources: [{ id: 'resource3', label: 'Resource 3' }, { id: 'resource4', label: 'Resource 4' }]
},
{
label: 'Task D',
dateStart: '2026-06-28',
duration: 1000,
progress: 20,
connections: [{ target: 5, type: 1 }]
},
{
label: 'Task E',
dateStart: '2026-07-28',
dateEnd: '2026-09-06',
progress: 50,
resources: [{ id: 'resource5', label: 'Resource 5' }]
},
{
label: 'Project B',
dateStart: '2026-09-07',
dateEnd: '2026-10-06',
type: 'project',
expanded: true,
synchronized: true,
tasks: [
{
label: 'Task A',
dateStart: '2026-10-08',
dateEnd: '2026-11-07',
connections: [{ target: 8, type: 1 }]
},
{
label: 'Task C',
dateStart: '2026-10-13',
dateEnd: '2026-11-27',
connections: [{ target: 9, type: 1 }]
},
{
label: 'Task B',
dateStart: '2026-10-28',
dateEnd: '2026-12-27',
progress: 10,
resources: [{ id: 'resource6', label: 'Resource 6' }]
}
]
}
]
});
};
<div>
<p>Gantt Chart can be sorted by columns by clicking on the header of the desired column. The first click on
the header will sort the Tasks in 'ascending' order. Second click will sort them in 'descending' and the
third will remove the sorting.</p>
</div>
<div id="gantt"></div>
<div style="position: absolute; bottom: 5px; right: 5px;">
<a href="https://www.jqwidgets.com/" alt="https://www.jqwidgets.com/"><img alt="https://www.jqwidgets.com/" title="https://www.jqwidgets.com/" src="https://www.jqwidgets.com/wp-content/design/i/logo-jqwidgets.png"></a>
</div>