To render boolean values as checkbox in columns, you need to set displayAsCheckBox
property as true.
import { Gantt } from '@syncfusion/ej2-gantt';
import { GanttData } from 'datasource.ts';
let gantt: Gantt = new Gantt({
dataSource: GanttData,
taskFields: {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
child: 'subtasks',
verified: 'verified'
},
splitterSettings: {
columnIndex: 5
},
height: '450px',
columns: [
{ field: 'TaskID', headerText: 'Task ID' },
{ field: 'Progress', headerText: 'Progress' },
{ field: 'TaskName', headerText: 'Task Name' },
{ field: 'StartDate', headerText: 'Start Date' },
{ field: 'verified', headerText: 'Verified', displayAsCheckBox: true, type: 'boolean' },
{ field: 'Duration', headerText: 'Duration' }
]
});
gantt.appendTo('#Gantt');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Gantt</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript Gantt Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/21.1.35/material.css" rel="stylesheet" type="text/css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='Gantt'></div>
</div>
</body>
</html>
You can enable or disable gantt action for a particular column by setting the allowFiltering
, allowSorting
, allowReordering
, and allowEditing
properties.
import { Gantt, Filter, Sort, Resize, ColumnMenu, Reorder, Selection, Edit } from '@syncfusion/ej2-gantt';
import { GanttData } from 'datasource.ts';
Gantt.Inject(Edit, Selection, Filter, Sort, Resize, Reorder);
let gantt: Gantt = new Gantt({
dataSource: GanttData,
taskFields: {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
child: 'subtasks'
},
allowFiltering: true,
allowSorting: true,
allowReordering: true,
splitterSettings: {
position: '75%'
},
editSettings: {
allowEditing: true
},
height: '450px',
columns: [
{ field: 'TaskID', headerText: 'Task ID' },
{ field: 'Progress', headerText: 'Progress', allowReordering: false },
{ field: 'TaskName', headerText: 'Task Name', allowSorting: false },
{ field: 'StartDate', headerText: 'Start Date', allowEditing: false },
{ field: 'Duration', headerText: 'Duration', allowFiltering: false }
]
});
gantt.appendTo('#Gantt');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Gantt</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript Gantt Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/21.1.35/material.css" rel="stylesheet" type="text/css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='Gantt'></div>
</div>
</body>
</html>
Column type can be specified using the columns.type
property. It specifies the type of data the column binds.
If the format
is defined for a column, the column uses type
to select the appropriate format option number or date.
Gantt column supports the following types:
If the
type
is not defined, it will be determined from the first record of thedataSource
. In case if the first record of thedataSource
is null/blank value for a column then it is necessary to define thetype
for that column.