Hi there,
I was working on the TreeView Control, and I was trying to configure the behaviour of the nodes so that if I double click on them, they would do my custom action. I was able to attach the function to each node, but I also notice that if I double click on the node, the node would also open up its child node list. Just wondering if there is a way to configure or disable this function so that when I double click on my node, it would only perform my action without expanding the child node list?
Many thanks,
Below is the code snippet
<div class="control-section">
<div class="control_wrapper" >
<ejs-treeview id="treedata" loadOnDemand ="false">
<e-treeview-fields child="ViewBag.child" dataSource="ViewBag.dataSource" id="nodeId" parentId="pid" text="nodeText" hasChildren="hasChild" expanded="expanded"></e-treeview-fields>
</ejs-treeview>
</div>
</div>
<script>
window.onload = function ()
{
var treedata = document.getElementById("treedata");
var instance = treedata.ej2_instances[0];
let nodes = instance.element.querySelectorAll('.e-list-item');
for (let i = 0; i < nodes.length; i++)
{
let element = nodes[i];
let button = element.querySelector(".e-fullrow");
button.addEventListener('dblclick', handleDoubleClick);
}
}
function handleDoubleClick()
{
console.log("double clicked");
}
</script>
|
<ejs-treeview id="treedata" expandOn="None" showCheckBox="true">
<e-treeview-fields dataSource="ViewBag.dataSource" id="id" parentId="pid" text="name" hasChildren="hasChild" expanded="expanded"></e-treeview-fields>
</ejs-treeview>
<script>
window.onload = function () {
var treedata = document.getElementById("treedata");
var instance = treedata.ej2_instances[0];
let nodes = instance.element.querySelectorAll('.e-list-item');
for (let i = 0; i < nodes.length; i++) {
let element = nodes[i];
let button = element.querySelector(".e-fullrow");
button.addEventListener('dblclick', handleDoubleClick);
}
function handleDoubleClick() {
alert("double clicked");
}
</script> |
Thank you for your answer. This works like a charm