jsTree: How to *set* opened/selected node by path (not ID)?

时间:2017-08-13 13:42:10

标签: jstree

So, I can get the full path of a selected node like so (thanks to @ggrandes for that one):

.on('changed.jstree', function (e, data) {
  var path = data.instance.get_path(data.node,'/');
  console.log('Selected: ' + path); 
})

What I now need, is to set select/open a node according to a given path.

All the solutions I've found so far refer to some mysterious ID, which appears to simply assume that the data in question has IDs. My problem is that I don't. It's simply a recursive JSON dict/array describing a directory layout. All I have with each node, is its name and a list of its children (and their names and children and so forth).

So, what I need is something like:

data.instance.set_path('/some/arbitrary/path');

Is it possible to do this with jsTree in some reasonable way?

1 个答案:

答案 0 :(得分:0)

我最终创建了服务器端每个项目的完整路径,并将其用作可在客户端选择的ID。据我所知,在撰写本文时,没有其他办法。

相关问题