Treegrid row disable selection but allow expand

Hello,

Is it possible to disable a single row on the treegrid (prevent the selection) but still allowing the expand button action ?

Thank you by advance,

Simon H.


2 Replies

PS Pon Selva Jeganathan Syncfusion Team July 2, 2022 05:13 AM UTC

Hi Hamery simon,


Thanks for contacting syncfusion forum.


We are working on this query with high priority. And we need time to find a feasible solution of your requirement and will update you with further details by 5th July 2022.  Until then we value your patience. Meanwhile, we will contact you if any details are required.


Regards,
Pon selva




PS Pon Selva Jeganathan Syncfusion Team July 5, 2022 01:18 PM UTC

Hi Hamery simon,


Thanks for your patience.


Query: Is it possible to disable a single row on the treegrid (prevent the selection) but still allowing the expand button action ?



We achieved your query by using the rowDeselecting event of the treegrid. You can prevent the deselection using rowDeselecting event of the treegrid with args.cancel as true.


Please refer to the below code example,


let treegridTreeGrid = new TreeGrid({

  dataSource: sampleData,

  childMapping: 'subtasks',

  ….

  rowDeselecting: function (args) {

    if (

      args.target.classList.contains('e-treegridexpand') ||

      args.target.classList.contains('e-treegridcollapse')

    ) {

      args.cancel = true;

    }

  },

 


Please refer to the below sample,

https://stackblitz.com/edit/rett8x?file=index.ts


Please refer to the below API documentation,

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


If the above solution does not meet your requirements, kindly share the detailed explanation of your requirement and share the video demo or screenshot of your requirement.


Kindly get back to us for further assistance.


Regards,
Pon selva




Loader.
Up arrow icon