JavaScript jqxGantt Task views.
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.tasks property – A getter that returns a flat structure as an array of all tasks inside the element.view property – Determines the viewing date range of the timeline.change event – This event is triggered when a Task is selected/unselected.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, jqxbuttons.js, jqxscrollbar.js, jqxlistbox.js, jqxdropdownlist.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', {
height: 'auto',
source: [
{
//Note: dateStart/dateEnd and min/max of syncronized projects are automatically calculated based on the tasks
label: 'Project 1',
dateStart: '2025-05-07',
dateEnd: '2026-06-08',
type: 'project',
expanded: true,
tasks: [
{
label: 'Task 1.1',
dateStart: '2025-02-07',
dateEnd: '2025-04-07',
type: 'task'
},
{
label: 'Task 1.2',
dateStart: '2025-03-24',
dateEnd: '2025-06-07',
type: 'task'
},
{
label: 'Milestone 1',
dateStart: '2025-04-18',
type: 'milestone'
},
{
label: 'Project 2',
dateStart: '2025-06-08',
dateEnd: '2026-12-29T23:59:59',
type: 'project',
expanded: true,
tasks: [
{
label: 'Task 2.1',
dateStart: '2025-06-09',
dateEnd: '2025-12-29',
type: 'task'
},
{
label: 'Task 2.2',
dateStart: '2024-12-30',
dateEnd: '2026-05-30',
type: 'task'
},
{
label: 'Milestone 2.1',
dateStart: '2025-06-27',
type: 'milestone'
},
{
label: 'Task 2.3',
dateStart: '2025-12-26T10:25:07',
dateEnd: '2025-12-28T9:0:0',
type: 'task'
}
]
}
]
}]
});
const viewSelector = new jqxDropDownList("#viewSelector", {
source: [
{ label: 'Year', value: 'year' },
{ label: 'Month', value: 'month' },
{ label: 'Week', value: 'week' },
{ label: 'Day', value: 'day' }
],
autoDropDownHeight: true
});
viewSelector.val('year');
viewSelector.host.on('change', (event) => {
gantt.setOptions('view', viewSelector.val());
});
}
<div id="gantt"></div>
<br>
<div>Select a view:</div>
<div id="viewSelector"></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>