We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Expand without selection

I'm sure I've simply missed something in the documentation and Demo.  If I have 'rowSelected' event defined on the treegrid, if I click on the expand icon, the rowSelected event is triggered.  Is there a way to not select the row if the expand icon has been clicked?

<ejs-treegrid id="TreeGrid1" dataSource="@ViewBag.datasource1" idMapping="O6CNT" parentIdMapping='O6PRNT' enableCollapseAll="true" treeColumnIndex="0" allowSelection="true" rowSelected="rowselected">
    <e-treegrid-selectionsettings mode="Row"></e-treegrid-selectionsettings>
    <e-treegrid-columns>
        <e-treegrid-column field="O6ORDNUM" headerText="Ord #" textAlign="Right" width="20"></e-treegrid-column>
        <e-treegrid-column field="O6ITEM" headerText="Item#" width="20">></e-treegrid-column>
        <e-treegrid-column field="ODPN" headerText="Part" width="20">></e-treegrid-column>
        <e-treegrid-column field="ODTEXT" headerText="Description" width="60"></e-treegrid-column>
    </e-treegrid-columns>
</ejs-treegrid>


3 Replies

RR Rajapandi Ravi Syncfusion Team November 20, 2019 01:16 PM UTC

Hi Patrick, 

Thanks for using syncfusion support. 

Query#: Is there a way to not select the row if the expand icon has been clicked? 
 
Yes, We have achieved your requirement by using rowSelecting event. This event gets fired before the rowSelected event, So here we have prevent the selection based on the target. Please refer the below code example for more information. 

<ejs-treegrid id="tree1" rowSelecting="rowselecting" allowPaging="true" dataSource="@ViewBag.datasource" idMapping="TaskId" parentIdMapping="ParentId" treeColumnIndex="0" > 
        <e-treegrid-columns> 
            .  .  .  .  .  .  . 
            .  .  .  .  .  .  . 
        </e-treegrid-columns> 
    </ejs-treegrid> 
 
<script> 
    function rowselecting(args) { 
        if (args.target.classList.contains("e-treegridexpand")) { 
           args.cancel = true;            // It helps to not triggering the rowselected event 
        } 
    } 
    </script> 

Regards, 
Rajapandi R


PK Patrick King November 20, 2019 09:19 PM UTC

Thanks so much for the quick response.  This worked perfectly.  I did add e-treegridcollapse to the condition and my rowselected function only processed when not expanding or collapsing the grid.


PK Padmavathy Kamalanathan Syncfusion Team November 21, 2019 04:05 AM UTC

Hi Patrick,

Thanks for your update. We are happy to hear that your issue has been resolved.

Feel free to get back to us if you need further assistance.

Regards,
Padmavathy Kamalanathan


Loader.
Live Chat Icon For mobile
Up arrow icon