How to do row selection when using rowTemplate in Treegrid

Hi,

I have a treegrid in which I am using rowTemplate. Wanted to check if rowSelection is possible while using a rowTemplate in treegrid?

I so far have been unsuccessful in doing so.

I also tried using an onClick event in the the rowTemplate, but that is also not working out.

Any suggesitopns on this would be helpful.


3 Replies

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team August 31, 2022 12:11 PM UTC

Hi Aravind ,


We don’t have the selection support while using rowTemplate. Using rowTemplate feature we can able to render the dynamic elements. So, its not feasible to select all the dynamic elements. We can achieve this through workaround by applying the CSS styles to the row.


Regards,

Farveen sulthana T



AR Aravind Rajagopal August 31, 2022 01:33 PM UTC

Could you give an example of the css styling to select a row ?



PS Pon Selva Jeganathan Syncfusion Team September 1, 2022 06:27 PM UTC

Hi Aravind,


Thanks for the update.


Query:Could you give an example of the css styling to select a row ?


We achieved your query by using the load event of the Treegrid and click event.


Please refer to the below code example,

 load: function (args) {

    treegrid.element.addEventListener('click', (args=> {

      args.target.closest('tr').classList.add('bgcolor');

    });

  },

});

 


In the above code snippet, we highlighted the color while click on the row.


Please refer to the below screenshot,



Please refer to the below API documentation,

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


Please let us know if you have any concerns.


Regards, 

Pon selva  


Loader.
Up arrow icon