Treeview Doubleclick on Node

Hi

I am trying to execute a dblclick event on a treenode.

For this I used the Nodeclicked event and want to catch the number of clicks with args.event.tapCount.

This works on the nodeExpanding event but not here.

Is there a way to get the dblclick event on the node.


Thanks for the help


<ejs-treeview id="treedata" animation="anim" cssClass="custom" expandOn="None" nodeClicked="nodeClick" nodeExpanding="nodeExpanding" EnablePersistence="true">
<e-treeview-fields id="CategoryID" datasource="TreeDataSource" parentId="ParentID" text="Name" hasChildren="hasChild" expanded="true"></e-treeview-fields>
</ejs-treeview>


<script>
function nodeClick(args) {
var treeObj = document.getElementById('treedata').ej2_instances[0];
var targetNodeId = treeObj.selectedNodes[0];

// Does not work
if(args.event.tapCount==2 ){
// do something
}
}


function nodeExpanding(args) {
// Works
if(args.event.tapCount==2 ){
args.cancel=true;
}
}

</script>

3 Replies

LD LeoLavanya Dhanaraj Syncfusion Team April 28, 2022 04:00 PM UTC

Hi Reto,

Greetings from Syncfusion support.

We have validated your requirement in the TreeView component. Currently, we have not provided support to get the tap count in the NodeClicked event of TreeView. To achieve your requirement, we suggest you bind the double click event for the TreeView component as shown in the below code snippet.


[index.cshtml]

document.addEventListener('DOMContentLoaded'function () {

  document.getElementById("treeData").addEventListener("dblclick"function ()

  {

      console.log("onDoubleClick is trigerred");

  });

});


You can find the sample from below link.


Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/TreeViewDoubleClick755229446.zip


Please get back to us if you need any further assistance.


Regards,

Leo Lavanya Dhanaraj



RR Reto Ruemmeli May 1, 2022 09:12 AM UTC

Hi Leo


I have tested it also in combination with a Contexmenu and the nodeClick event. Everything worked.


Thanks a lot


kind regards, Reto



IL Indhumathy Loganathan Syncfusion Team May 2, 2022 05:44 AM UTC

Hi Leo,


We are glad that your reported issue has been resolved. Please get back to us if you need any further assistance.


Regards,

Indhumathy L


Loader.
Up arrow icon