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
close icon

Can a link in a treeview node respond to its own event handler?

Hello,

I have a TreeView using templates.  I am wondering if it's possible to have a link inside of a node that responds to it's own click event and not the nodeClick event of the tree.  For example here is a template:

<script id="treeTemplate" type="text/x-jsrender">
<table>
    <tr>
        <td>{{>FirstName}}</td>                            
<td>{{>LastName}}</td>
        <td><a onclick="{{>SomeURL}}"><img src="{{>SomeIconPath}}" /></a></td>
   </tr>
</table>
</script>

So, clicking the <img/> tag would fire the onClick event of the anchor tag, and not the nodeClick event of the tree.

Thanks,

Randy





1 Reply

SN Sasikala Nagarajan Syncfusion Team July 22, 2015 03:59 AM UTC

Hi Randy,
Thanks for using Syncfusion products,

We have analyzed your query. We can achieve your requirement using our link Attribute feild property of Treeview. This property is used to set the hyper link of node. We have prepared the simple sample based on this. Please get the sample from below location

Sample

If you didn’t need treeview node click event in this case, you can achieve this by cancelling the particular event. This can be done by setting cancel argument value to true(cancel is one of the argument of node click event).Please refer the below code snippet

$("#treeview").ejTreeView({

fields: {

dataSource: treeData,

id: "id", parentId: "pid", text: "name", hasChild: "hasChild", linkAttribute: "linkAttribute"

},

template: "#treeTemplate", nodeClick: "nodeClick"

});

function nodeClick(args) {

args.cancel = false;

}


Please check with the provided sample and let us know if you have further queries,
Regards,
Sasikala Nagarajan

Loader.
Live Chat Icon For mobile
Up arrow icon