Closed WriterStat closed 2 years ago
I don't understand what you mean with the 'index'. Do you mean the id?
Hi Marco, I'm going to try using:
var np = node.parent;
const pind = np.parent.getChildIndex(node);
const eind = node.parent.getChildIndex(node);
console.log('pind: '+pind);
console.log('eIind: '+eind);
To test...
Index in object for the parent. Index in the parent's children for the current node.
Not sure if I have that quite right. But will figure it out better when I test.
Figured it out, In case this helps anyone, but we may be the only one who needed this =) :
var node = $tree.tree("getNodeById", nid);
if (node) {
'const np = node.parent;
const parent_index = np.parent.getChildIndex(np);
const child_index = node.parent.getChildIndex(node);
console.log('parent_index: '+parent_index);
console.log('child_index: '+child_index);
}`
We pass around our own internal array of objects(2 levels) which corresponds in some ways to the jqTree one. When changes happen in the jqTree having the parent and child index allows us to then update our own internal array automatically.
Cheers, I should have tested first. Will close.
Hey Marco,
Best way to get index of node?
Thanks!