Dynatree - Where can I store additional information in each node?

I'm currently testing Dynatree, and I just want to ask if there is an available property / parameter in which I can store additional information (for example, the value of the 'property in ASP.NET TreeView) for each node? Thanks in advance.

+6
source share
2 answers

You can add custom properties using HTML with a data attribute (works, although the validator may complain.)

For example, add a new url property:

<ul> <li data="url: 'http://jquery.com'">jQuery home <li data="url: 'http://docs.jquery.com'">jQuery docs 

Or when loading from JSON or JS objects:

 children: [ { title: "jQuery home", url: "http://jquery.com" }, { title: "jQuery docs", url: "http://docs.jquery.com" }, 

After that, you can access it like this:

 onActivate: function(node) { if( node.data.url ) window.open(node.data.url); $("#echoActive").text(node.data.title); }, 

EDIT: Since release 1.2 <a> tags are supported based on ( How do I make hyperlinks in the jQuery dynaTree plugin clickable? ).

+6
source

If you are adding read data using dynatree then mar10 is correct. For example, if you want dynatree not to display icons, you can use the following:

 <li data="icon: 'null'"> 

Unfortunately, this is not entirely correct HTML, and my HTML5 validator (Visual Studio 2010 SP1) likes to complain about it.

If you just want to embed your own data, HTML5 allows you to add data- * attributes to your li elements:

 <li data-myprop="myvalue"> 

Here is additional information from HTML5Doctor .

0
source

Source: https://habr.com/ru/post/888172/


All Articles