Bootstrap Treeview - find node by property value

1.2k views Asked by At

I'm using Bootstrap Treeview to display hierarchical date. The node data is retrieved using a call to a Web API endpoint and the data includes other name/value pairs, including a unique ID number, which are added as node properties.

I would like to select a node, given that unique ID number, but this doesn't look possible.

The selectNode method accepts either a node object or the nodeId that is automatically assigned to the node (not sure how to use this as it's not possible to predict or discover what this is!).

There is a search method, but this only seems to search the text property of the nodes.

Ideally, I'm looking for something like a lambda expression in the search method that can specify the property to be searched, e.g.

var node = $('#tree').treeview('search', [n => n.MyProperty == '123345']);

Is this at all possible? Is there another way to achieve this?

I've done a lot of work to get things working and this is the final hurdle. Would I be better switching to jsTree?

Thanks in advance.

1

There are 1 answers

0
Doug On

The answer is to use jsTree. Worked perfectly!