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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

119664 Jul 20,2015 11:27 AM Jul 21,2015 11:59 PM JavaScript 1
loading
Tags: ejTreeView
Randy Craven
Asked On July 20, 2015 11:27 AM

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





Sasikala Nagarajan [Syncfusion]
Replied On July 21, 2015 11:59 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;