Setting Hierarchy mode for TreeGrid

I have this line of code:

this.treegridCompliance22.filterSettings.hierarchyMode = “Both”

That’s ok, but my problem is the treegrid in question is hidden initially so I can’t put it in OnInit. That’ll generate undefined errors since it doesn’t know what it is yet.


Is there a way to put that in here?


public treegridCompliance22: TreeGridComponent;

dataBoundCompliance22(args) {

  Object.assign((this.treegridCompliance22.grid.filterModule as any).filterOperators, { startsWith: 'contains' });

  }


Or otherwise include it in the treegrid definition?

<ejs-treegrid #treegridCompliance22 id='treegridCompliance22' [dataSource]='ticketsByComplianceLineItem' 

                               [treeColumnIndex]='0' childMapping='subitems' width = '1400'  height = '315' allowEditing= 'true' 

                               [allowFiltering]='true'     (dataBound)='dataBoundCompliance22()'

                               allowTextWrap='true' [textWrapSettings]='wrapSettings' 

                                                           [allowExcelExport]='true'> 


Such that it’ll set the hierarchy mode to “Both” even though the control is initially hidden?


Thanks




3 Replies

PS Pon Selva Jeganathan Syncfusion Team July 14, 2021 11:27 AM UTC

Hi Walter,   
 
Thanks for contacting syncfusion forum. 
 

Query: Setting Hierarchy mode for TreeGrid

From your query, we suspect that you want to set the hierarchyMode on initial rendering but not on the onInit method. We achieved this requirement by using load events of the tree grid.

Please refer to the below code snippet,


  
 <ejs-treegrid #treegrid [dataSource]='data' allowPaging='true' height='350' allowFiltering='true' 
        [pageSettings]='pageSettings' (load)="load()" childMapping='subtasks' [treeColumnIndex]='1'> 
        <e-columns> 
  
  
 
App.component.ts 
…. 
 
 load() { 
    (this.treegrid as any).filterSettings.hierarchyMode = 'Both'; 
  } 
 
 

Please refer to the below sample,

https://stackblitz.com/edit/angular-jnrnn6?file=app.component.ts

Please refer to the below API documentation,

https://ej2.syncfusion.com/angular/documentation/api/treegrid/#load

Please get back to us if you need any further assistance.   
 
Regards,   
Pon selva   
 



WC Walter Cook July 14, 2021 01:11 PM UTC

Perfect!

Thanks very much



PS Pon Selva Jeganathan Syncfusion Team July 15, 2021 12:46 PM UTC

Hi Walter,   
  
Thanks for the update.    
  
Kindly get back to us for further assistance. We are happy to assist you. 
  
Regards,  
Pon selva  


Loader.
Up arrow icon