javascript - How do we get index of select node in a extjs tree? -
on page have 2 trees. there form on page. 1 tree shown on page , inside form. have create trees below:
var mytree1 = ext.create('ext.tree.panel', { store: store, //where store hardcoded json tree data .... });
similarly mytree2 declared different store. shown inside form. when select on node on mytree2 , click on create button must able add new leaf node inside mytree1 @ same index.
help need are:
1. how index of selected node.
2. how go index in mytree1, should equal selected index mytree2.
3. how add leaf node @ specific index.
for reference:
ext js 4 treepanel documentation
ext js 4 nodeinterface documentation
the
select
event provides both index , record. if need general access it,mytree1.getselectionmodel().getselection()
return array of records, can check against store index.i'm assuming want compare selected records on both trees. given sample in #1, try this:
var tree1rec = mytree1.getselectionmodel().getselection[0], tree2rec = mytree2.getselectionmodel().getselection[0]; // perform comparison logic here // note if you're using 2 different stores, can't // equality test. you'll have compare // individual store values.
nodes inserted relative existing nodes on tree. if have button click event:
function onbuttonclick(button, eopts) { var rec = mytree1.getselectionmodel().getselection[0]; if (rec) { var childnode = rec.createnode(/* object here */); rec.appendchild(childnode); } }
the details vary depending on actual data, general pattern.
Comments
Post a Comment