Skip to main content

Getting label of the selected node in a tree

2 replies [Last post]
kjambor
Offline
Joined: 2004-04-19
Points: 0

I just upgraded my jmaki application to jmaki 1.0.
For some reason the node.label in my event handler for yahoo.tree is returning undefined. I expected the value to be the label of the node I clicked on.

Any one had the same issue? Am I doing something wrong?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kjambor
Offline
Joined: 2004-04-19
Points: 0

Hi,

Your suggestion will work for me.

-- Kamyar

gmurray71
Offline
Joined: 2003-07-31
Points: 0

Hi,

The tree model listed at:

http://wiki.java.net/bin/view/Projects/jMakiTreeDataModel

The label of the node is not part of the published contract. What gets published is the id of the tree node.

Publishing the label as part of the payload would mix the visual part of jmaki with the data / events.

You do have one other option and that is to associate an 'action' with the node of choice which you can attach any type of data you like as part of the message.

For example the following node:

{ label : 'Node 3.1',
action : { topic : '/foo/select', message : {targetId : 'bar'}}
}

Could be:

{ label : 'Node 3.1',
action : { topic : '/foo/doSomething', message : {targetId : 'bar', myLabel : 'Node 3.1'}}
}

and you can add any arbitrary properties as part of the message you would like.

This let's us keep a clean contract that is consistent across trees, tables, comboboxes and still provides some level of extensibility.

Will this work for you?