How to programmatically select the node or multiple nodes in JSTREE by using its text?

1,144 views
Skip to first unread message

Tree Rocker

unread,
Apr 25, 2014, 9:54:35 AM4/25/14
to jst...@googlegroups.com
I want to select nodes by using its text because server returns its text.
Now I have to select those nodes. Please provide me the solution for the same.

Nodes can be child nodes as JSTREE added nodes while we expand. So I think we have to select the tree from its data.

Please help me. Thanks in advance:)

Ivan Bozhanov

unread,
Apr 25, 2014, 11:02:10 AM4/25/14
to jst...@googlegroups.com
Well, you can use search ... but that won't be very accurate. To select by name you'd have to cycle through all data:
var arr = [];
$.each(instance._model.data, function (i, v) {
  if($.inArray(v.text, ['array','of','titles'])) { arr.push(i); }
});
instance.select_node(arr);

Give this a try - not tested but it should work.

Best regards,
Ivan
Reply all
Reply to author
Forward
0 new messages