Support Forum
Hi
As you can see there are BaseLine Start and BaseLine Finish column in gantt grid. The values are only shown at child level of parent as for each child i am passing from backend. Apart from that i have startDate and endDate at level which i am passing from backend and in gantt view tooltips shows the value at parent level which gantt is auto rolling .same roll up i want to do at grid for any column for now let us base Line start and base Line finish date. Attach is project and above thread you can find screen shot. It is angular Project
As you can see there are BaseLine Start and BaseLine Finish column in gantt grid. The values are only shown at child level of parent as for each child i am passing from backend. Apart from that i have startDate and endDate at level which i am passing from backend and in gantt view tooltips shows the value at parent level which gantt is auto rolling .same roll up i want to do at grid for any column for now let us base Line start and base Line finish date. Attach is project and above thread you can find screen shot. It is angular Project
- Attachments
-
- advanced-fo.rar
- (1.81 MiB) Downloaded 94 times
Hi!
We have new AggregateColumn which is available in latest nightly build at CustomerZone suffixed with -next.
You could use function column config to provide your own aggregation method.
Demo can be found in distribution package in examples/aggregation-column
Also you could check this sample code which aggregates cost value and replace code inside on('update', ({ record, changes }) method to obtain your data from children.
We have new AggregateColumn which is available in latest nightly build at CustomerZone suffixed with -next.
You could use function column config to provide your own aggregation method.
Demo can be found in distribution package in examples/aggregation-column
Also you could check this sample code which aggregates cost value and replace code inside on('update', ({ record, changes }) method to obtain your data from children.
class MyTaskModel extends TaskModel {
static get fields() {
return [
{ name : 'cost', type : 'number' }
];
}
}
const
project = new ProjectModel({
taskModelClass : MyTaskModel,
transport : {
load : {
url : '../_datasets/launch-saas.json'
}
}
}),
gantt = new Gantt({
appendTo : 'container',
project : project,
columns : [
{ type : 'name', field : 'name', width : 250 },
{ type : 'startdate' },
{ type : 'duration' },
{
type : 'number',
text : 'Cost<br><span style="font-size:0.8em">(aggregated)</span>',
align : 'right',
field : 'cost',
width : 100,
htmlEncode : false,
renderer : ({ record, value }) => record.isLeaf ? `$${value}` : `<b>$${value}</b>`
}
],
features : {
taskEdit : {
editorConfig : {
height : '37em',
extraItems : {
generaltab : [
{
html : '',
ref : 'costGroup',
dataset : {
text : 'Cost'
},
cls : 'b-divider',
flex : '1 0 100%'
},
{
type : 'number',
ref : 'costField',
name : 'cost',
label : 'Cost',
flex : '.5 0',
cls : 'b-inline'
}
]
}
}
}
},
listeners : {
// Disable Cost editing for parent tasks
beforeCellEditStart : ({ editorContext }) => editorContext.record.isLeaf,
beforeTaskEdit : ({ taskRecord }) => {
gantt.taskEdit.editor.widgetMap.costField.disabled = !taskRecord.isLeaf;
}
}
});
project.load().then(() => {
const rndGen = new RandomGenerator();
// Set random cost for each child task
gantt.taskStore.traverse(task => {
task.cost = task.isLeaf ? rndGen.nextRandom(100) : 0;
});
});
// Listen to update events on taskStore to calculate sum for customField
project.taskStore.on('update', ({ record, changes }) => {
const parent = record.parent;
// Sum parent's children values when record's field is changed and record has parent node
if (changes.cost && parent) {
// Children for parent node or empty array for record without children
const children = parent && parent.children || [];
parent.cost = children.reduce((a, v) => {
// If record has no field then we use 0 value
return a + parseInt(v.cost || 0);
},
// Initial value is 0
0);
}
});