igTree calling igTree('select', x) to set focus. Node x obtained via igTree('nodeByIndex'...) get an error

775 views Asked by At

In javascript, I'm trying to set the focus (selected) node in an igTree using the igTree('select', node) method. When I use a node obtained from an event (such as Changing) this select method works fine.

In this case, though, I'm trying to use one of the igTree methods to get the node I'm passing to igTree('select' ...).

I can see that the node object I'm getting is the correct one. The path is "2_3", which is correct. However, the select is throwing an error:

Uncaught TypeError: node.attr is not a function

I'm using knockout.js bindings to create the tree. The bindings are two levels deep and the binding structure at each level is identical.

Using the latest version of IgniteUI and using ui.igTree object.

Infragistics seems to be having problems with their forums.

Any idea why this would not work?

1

There are 1 answers

0
Konstantin Dinev On

The select method takes a jQuery element as a parameter. The node object returned by nodeByIndex contains the element in it, so you need to call the method like this:

var node = $('#tree').igTree('nodeByIndex', index);
$('#tree').igTree('select', node.element);

If you use the nodeByPath method you will get a jQuery element directly instead of a node object.

var node = $('#tree').igTree('nodeByPath', "2_3");
$('#tree').igTree('select', node);