Hello,
You need to copy all the necessary code from the sources to get all the functionality you need.
The colHeader
variable is used in the header to create new tasks:
If you want to add buttons like in the following sample, you need to add the font-awesome library and add CSS rules:
https://docs.dhtmlx.com/gantt/samples/07_grid/07_custom_buttons.html
Font awesome:
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css?v=6.1.7">
Style rules:
<style>
html, body {
height: 100%;
padding: 0px;
margin: 0px;
overflow: hidden;
}
.fa {
cursor: pointer;
font-size: 14px;
text-align: center;
opacity: 0.2;
padding: 5px;
}
.fa:hover {
opacity: 1;
}
.fa-pencil {
color: #ffa011;
}
.fa-plus {
color: #328EA0;
}
.fa-times {
color: red;
}
</style>
Configuration:
var colHeader = '<div class="gantt_grid_head_cell gantt_grid_head_add" onclick="gantt.createTask()"></div>',
colContent = function (task) {
return ('<i class="fa gantt_button_grid gantt_grid_edit fa-pencil" onclick="clickGridButton(' + task.id + ', \'edit\')"></i>' +
'<i class="fa gantt_button_grid gantt_grid_add fa-plus" onclick="clickGridButton(' + task.id + ', \'add\')"></i>' +
'<i class="fa gantt_button_grid gantt_grid_delete fa-times" onclick="clickGridButton(' + task.id + ', \'delete\')"></i>');
};
gantt.config.columns = [
{name: "text", tree: true, width: '*', resize: true},
{name: "start_date", align: "center", resize: true},
{name: "duration", align: "center"},
{
name: "buttons",
label: colHeader,
width: 75,
template: colContent
}
];
function clickGridButton(id, action) {
switch (action) {
case "edit":
gantt.showLightbox(id);
break;
case "add":
gantt.createTask(null, id);
break;
case "delete":
gantt.confirm({
title: gantt.locale.labels.confirm_deleting_title,
text: gantt.locale.labels.confirm_deleting,
callback: function (res) {
if (res)
gantt.deleteTask(id);
}
});
break;
}
}
Here is the snippet with that functionality:
http://snippet.dhtmlx.com/b30025000
also scoller didnt work in greed
If you want to add the scrollbars in the grid, you need to change the layout configuration:
https://docs.dhtmlx.com/gantt/desktop__layout_config.html#scrollbar
First, it is better to use the rows inside columns structure (cols:[rows[]]
).
You need to specify the vertical and horizontal scrollbars for the grid and put them in the right place:
In the following snippet, you can see how it works:
http://snippet.dhtmlx.com/084e66435
So it’s showing new data, but if i want show only childs without parent its not working
If that task has the parent
parameter, but that parent task doesn’t exist, Gantt won’t the child task. There is no way to change that unless you modify the source code.
So, you need to load the data with parent tasks and hide them in the onBeforeTaskDisplay
event handler:
http://snippet.dhtmlx.com/95c9fa4fe
Or reassign the parent parameter:
http://snippet.dhtmlx.com/27b086415