Description
Multiple tasks with resources assigned to some of them are displayed inside the GanttChart.
Those that
do not have tasks assigned have a question mark. Projects are not allowed to have resources assigned to
them, thanks to the disableResources property.
A formatFunction is applied to the "Assignee" column which displays tasks with multiple resources assigned
in a different way.
The Resource Panel is hidden in order to see only the Tasks.
JavaScript jqxGantt view.
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.groupByResources property – Groups the tasks inside the Task timeline according to the resources they are assigned to.hideResourcePanel property – Hides the Resource panel regardless of the resources availability By default the Resource panel is visible if resources are added to the GanttChart.resources property – A getter that returns a flat structure as an array of all resources inside the element.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.timelineHeaderFormatFunction property – A format function for the Header of the Timeline.view property – Determines the viewing date range of the timeline.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", {
source: [
{
label: 'Office Configuration',
synchronized: true,
expanded: true,
type: 'task',
disableResources: true,
tasks: [
{
label: 'Office Setup',
synchronized: true,
expanded: true,
disableResources: true,
type: 'project',
tasks: [
{
label: 'Office Acquiring',
dateStart: '2025-12-29',
dateEnd: '2026-01-01',
type: 'task',
connections: [{ target: 3, type: 1 }],
resources: [{ id: 'taylor', label: 'Taylor' }, { id: 'michael', label: 'Michael' }]
},
{
label: 'Office Interior',
dateStart: '2026-01-01',
dateEnd: '2026-01-11',
type: 'task',
connections: [{ target: 4, type: 0 }],
resources: [{ id: 'anna', label: 'Anna' }, { id: 'samantha', label: 'Samantha' }, { id: 'christina', label: 'Christina' }]
},
{
label: 'Office Security',
dateStart: '2026-01-01',
dateEnd: '2026-01-06',
type: 'task',
connections: [{ target: 5, type: 1 }],
resources: { id: 'tommy', label: 'Tommy' }
}
]
},
{
label: 'Employee Positioning',
dateStart: '2026-01-07',
dateEnd: '2026-01-11',
type: 'task',
resources: { id: 'carol', label: 'Carol' }
},
{
label: 'Cleaners',
dateStart: '2026-01-06',
dateEnd: '2026-01-11',
type: 'task',
resources: { id: 'rachel', label: 'Rachel' }
},
{
label: 'Catering',
dateStart: '2026-01-07',
dateEnd: '2026-01-12',
type: 'task'
},
{
label: 'Transport',
dateStart: '2026-01-08',
dateEnd: '2026-01-13',
type: 'task'
},
{
label: 'Human Resources',
dateStart: '2026-01-06',
dateEnd: '2026-01-16',
type: 'task',
resources: [{ id: 'annabell', label: 'Annabell' }, { id: 'monica', label: 'Monica' }]
}
]
},
{
label: 'Operations',
synchronized: true,
expanded: true,
disableResources: true,
type: 'project',
tasks: [
{
label: 'Development',
dateStart: '2026-01-16',
dateEnd: '2026-01-28',
type: 'task',
resources: [{ id: 'jason', label: 'Jason' }, { id: 'aaron', label: 'Aaron' }]
},
{
label: 'Marketing',
dateStart: '2026-01-06',
dateEnd: '2026-01-27',
type: 'task',
resources: { id: 'sonya', label: 'Sonya' }
},
{
label: 'Quality Assurance',
dateStart: '2026-01-28',
dateEnd: '2026-02-01',
type: 'task',
resources: { id: 'rick', label: 'Rick' }
},
{
label: 'Market Researchers',
dateStart: '2025-12-28',
dateEnd: '2026-01-01',
type: 'task',
resources: ['jason', 'sonya']
},
{
label: 'Managers',
dateStart: '2026-01-16',
dateEnd: '2026-01-27',
type: 'task',
resources: { id: 'ryan', label: 'Ryan' }
}
]
},
{
label: 'Production',
synchronized: true,
expanded: true,
disableResources: true,
type: 'project',
progress: 50,
resources: 4,
tasks: [
{
label: 'Technology',
synchronized: true,
expanded: true,
disableResources: true,
type: 'project',
tasks: [
{
label: 'Updates',
dateStart: '2026-01-12',
dateEnd: '2026-01-16',
type: 'task',
connections: [{ target: 19, type: 0 }],
resources: { id: 'oliver', label: 'Oliver' }
},
{
label: 'Lifecycle',
dateStart: '2026-01-12',
dateEnd: '2026-01-14',
type: 'task',
connections: [{ target: 20, type: 1 }],
},
{
label: 'Testing',
dateStart: '2026-01-16',
dateEnd: '2026-01-21',
type: 'task',
resources: { id: 'jessica', label: 'Jessica' }
}
]
},
{
label: 'Servers and Backup',
dateStart: '2026-01-06',
dateEnd: '2026-01-08',
type: 'task',
resources: 'oliver'
},
{
label: 'Meetings',
dateStart: '2026-01-08',
dateEnd: '2026-01-11',
type: 'task',
resources: 'ryan'
},
{
label: 'Feedback and Improvements',
dateStart: '2026-01-28',
dateEnd: '2026-02-06',
type: 'task'
}
]
}
],
taskColumns: [
{
label: 'Task Name',
value: 'label',
size: '40%'
},
{
label: 'Start Time',
value: 'dateStart',
size: '25%'
},
{
label: 'Assignee',
value: 'resources',
size: '20%',
formatFunction: function (value, item) {
const gantt = document.querySelector('jqx-gantt-chart'), resources = gantt.resources, tasks = gantt.tasks, getResource = (d) => resources.find((res) => res.id.toString() === d.toString());
if (!item || item.disableResources) {
return '';
}
const itemResources = item.resources;
if (!itemResources.length) {
return '<span class="gantt-chart-task-assignee unassigned">?</span>';
}
else if (itemResources.length === 1) {
return `<span>${getResource(itemResources[0]).label}</span>`;
}
else {
let result = '';
for (let i = 0; i < itemResources.length; i++) {
const resource = getResource(itemResources[i]);
if (resource) {
result += `<span class="gantt-chart-task-assignee ${resource.id.toLowerCase()}">${resource.label.charAt(0)}</span>`;
}
}
return result;
}
}
},
{
label: 'Duration',
value: 'duration'
},
],
treeSize: '30%',
durationUnit: 'day',
hideResourcePanel: true,
groupByResources: true,
view: 'week',
timelineHeaderFormatFunction: function (date, type) {
const gantt = document.querySelector('jqx-gantt-chart'), monthFormat = gantt.monthFormat;
if (type === 'week') {
const startDayOfWeek = new Date(date), endDateOfWeek = new Date(date);
endDateOfWeek.setDate(date.getDate() + 6);
return startDayOfWeek.toLocaleDateString(gantt.locale, { day: 'numeric', month: monthFormat, year: gantt.yearFormat }) + ' - ' +
endDateOfWeek.toLocaleDateString(gantt.locale, { day: 'numeric', month: monthFormat, year: gantt.yearFormat });
}
if (type === 'day') {
return date.toLocaleDateString(gantt.locale, { day: 'numeric', month: monthFormat });
}
}
})
};
<div>
<p>
<b>Description</b><br>
Multiple tasks with resources assigned to some of them are displayed inside the GanttChart. <br>Those that
do not have tasks assigned have a question mark. Projects are not allowed to have resources assigned to
them, thanks to the <b>disableResources</b> property.<br>
A formatFunction is applied to the "Assignee" column which displays tasks with multiple resources assigned
in a different way.
<br>The Resource Panel is hidden in order to see only the Tasks.
</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>