Hierarchy filtering - Is it possible to apply different filtering to different hierarchy levels

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


Attachment: screenshot_4bd8cce1.zip

4 Replies

PS Premkumar Sudalaimuthu Syncfusion Team March 1, 2022 09:23 AM UTC

Hi Juhi ,  
  
Yes, we have filter hierarchy modes to filter and display the tasks according to their hierarchy levels. The Gantt component supports a set of filtering modes with the filterSettings.hierarchyMode property. We have shared the types and behavior of hierarchy modes.   
  
.Parent - This is the default filter hierarchy mode in Gantt. The filtered records are displayed with their parent records.  
  
.Child - Displays the filtered records with their child record.  
  
.Both - Displays the filtered records with their both parent and child records.  
  
.None - Displays only the filtered records.  
  
Please refer to the below online documentation for more information about the hierarchy modes.  
  
  
Regards,  
Premkumar S  



JG Juhi Goswami March 3, 2022 01:09 AM UTC

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!



LA Lokesh Arjunan Syncfusion Team March 3, 2022 01:34 PM UTC

Hi Juhi 
 
We have forwarded your query to our dependent team and we will update you further details within two business days(7th March 2022). 
 
Until then we appreciate your patience. 
 
Regards, 
Lokesh 



PS Premkumar Sudalaimuthu Syncfusion Team March 7, 2022 03:04 PM UTC

Hi Juhi , 
  
Thanks for your patience  
  
Query: Is there a possibility to apply a certain filter to parent tasks (level 0) and other filter to child tasks (level 1)?  
  
Based on your query, we suspect that you want to filter the particular hierarchy. We achieved your query by setting the filter mode to Noneand disabling the child or parent row filter on the actionbegin event with args action as the filter, then preventing the filter action from using args. cancel as a true.  
 
In the below code sample, we have collect the parent value and child value and set the flag value.   
   
·       If you want to prevent the child row filtering (i.e., filter only level 0 records). We enable the flag value using a button click and, in the actionBegin event, we prevent the child value using args.cancel as true based on the condition. 
·       If you want to prevent the parent row from filtering (i.e., filter only level 1 records). We enable the flag value using a button click and, in the actionBegin event, we prevent the parent value using args.cancel as true based on the condition. 
  
  
Please refer to the below code snippet,  
  
  
 let parentvaluestring[] = [];  
let childvaluestring[] = [];  
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 
});  
 
  
Please refer to the below sample,  
  
If the above solution does not meet your requirement, kindly get back to us with the below requested details,  
  
  1. Please share the detailed explanation of your requirement
  2. confirm whether If you want to use a different filter value on parent and child, but the filter is applied to the same hierarchy level
  3. How to define the level 0 record filter or level 1 record filter?
  4. Kindly share the filtersetting’s hierarchymode details.
  5. Share us a video demo/screenshot of your requirement.
  
The provided information will be helpful to provide you response as early as possible.  
  
Regards,  
Premkumar S 


Loader.
Up arrow icon