Hi,
We are using the Gantt React component to display a 2-level hierarchy of Jobs (parent Gantt task) and Tasks (child Gantt task). We have implemented filtering and leveraged the filterByColumn method. The filtering can be applied to both Jobs and Tasks at the same time. When both filters are applied, we expect only certain Tasks belonging to certain Jobs to be visible. However, it looks like filterByColumn applies the specified filter to all Gantt tasks regardless of their hierarchy level. This results in displaying empty data, because it applies Task filters to their parent Jobs, and since no Job has any Task properties, it gets removed along with its children.
My question is, is there a way to apply some filtering to the 1st level tasks (Jobs) and the others to the 2nd level tasks (Tasks)?
Thanks in advance
Hi Premkumar,
Thank you for your answer. Yes, we are aware about this setting and we are using the Both value. However, my questions was a bit different, let me try to elaborate it. Is there a possibility to apply a certain filter to parent tasks (level 0) and other filter to child tasks (level 1)? In our example, we'd like to filter Jobs (parent items) and Tasks (child items) using different sets of filters, where each set is only applicable to a particular hierarchy level. Thanks!
|
let parentvalue: string[] = [];
let childvalue: string[] = [];
let parflag = false;
let chldflag = false;
let gantt: Gantt = new Gantt({
…
actionBegin: function (args) {
if (args.action == 'filter') {
debugger;
parentvalue = [];
childvalue = [];
for (var i = 0; i < gantt.dataSource.length; i++) {
if (gantt.dataSource[i].parentID != null) {
//collect the parent value(i.e level 0)
var value = gantt.dataSource[i].TaskName;
parentvalue.push(value);
} else {
var value = gantt.dataSource[i].TaskName; // collect the child value(i.e level 1)
childvalue.push(value);
}
}
if (
parentvalue.find(
(element) => element == args.currentFilterObject.value
) &&
parflag == true
) {
// check the filter value is parent or not
args.cancel = true; //prevent the defaulut action
parflag = false; // diable the parent filter
} else if (
childvalue.find(
(element) => element == args.currentFilterObject.value
) &&
chldflag == true
) {
// check the filter value is child or not
args.cancel = true; //prevernt the default filter action
chldflag = false; // disable the child filter
}
}
},
filterSettings: { type: 'Menu', hierarchyMode: 'None' },
});
gantt.appendTo('#Editing');
document.getElementById('parent').addEventListener('click', () => {
parflag = true; //enable the parent filter
});
document.getElementById('child').addEventListener('click', () => {
chldflag = true; // enable the child filter
}); |