A treeview TV uses a remote hierarchical data source.
A button click on the page launches some ajax whose done() handles an array of node data that is returned.
The nodes are nested as follows
and appended to a treeview
The treeview appends them correctly as
However, the problem is that the children dataSources for nodes One and Two do not get updated. The top level dataSource of TV does have get updated. I stepped through get() using developer tools and saw that the method was properly descending into the children dataSources to locate the target value... it just wasn't there :(
I have also tried doing a series of appends (using the original unnested data) and had a similar to worse problem (the TV nodes don't even get placed at the correct levels).
Can you suggest a technique that works for adding a new 'path' of nested nodes to TV from with my done() handler ?
A button click on the page launches some ajax whose done() handles an array of node data that is returned.
nodes =
[ { id:101, text:
"One"
, hasChildren:
true
}
, { id:201, text:
"Two"
, hasChildren:
true
}
, { id:301, text:
"Three"
, hasChildren:
false
}
]
for
(
var
i=1;i<nodes.length;i++) {
nodes[i-1].items = [ nodes[i] ];
}
TV.append ( nodes[0] );
One
+- Two
+- Three
uid101 = TV.dataSource.get(101);
// some uid
uid201 = TV.dataSource.get(201);
// undefined
uid301 = TV.dataSource.get(301);
// undefined
parent =
null
;
parent = TV.append ( nodes[0], parent );
parent = TV.append ( nodes[1], parent );
parent = TV.append ( nodes[2], parent );
Can you suggest a technique that works for adding a new 'path' of nested nodes to TV from with my done() handler ?