PDA

View Full Version : Extjs 4.2.1 indent and outdent tree nodes



sayaliingavale
21 Jul 2014, 6:06 AM
Hi,
I am using extjs 4.2.1. I want to use indent and outdent in tree grid.
If I select some nodes, I want to make the node above the selected node as parent to all selected nodes.

I have tried by getting selected node and appednchild method (to the node aboove selected)but in that case I have to select nodes sequentially so it didnt worked.

Please reply ASAP if any solution.
Thanks in advance.

mitchellsimoens
29 Jul 2014, 9:56 AM
I'm not 100% sure what you are asking. If you check a node, you want to have it moved to a different node?

sayaliingavale
29 Jul 2014, 9:50 PM
Hi Mitchell,
consider following link.

http://docs.sencha.com/extjs/4.2.2/extjs-build/examples/build/KitchenSink/ext-theme-neptune/#tree-grid

In this tree, suppose I want to move "fix light" and "reattach screen doors" to the next level means to make "decorate living room" as parent and the 2 nodes below as children of that. The code I have written for that is:-

var node = Ext.getCmp('gridtores').getSelectionModel().getSelection();
if(node[0].previousSibling){
var node1 = Ext.getCmp('tree').store.getByInternalId(node[0].previousSibling.internalId);
if(node1.isLeaf()){
node1.set('leaf',false);
}
for(var i=0;i<node.length;i++){
node1.appendChild(node[i]);
}
node1.expand();
}
This code works only if I select sequentially, means if I select "fix light" and "reattach screen doors" sequentially not reverse. If I select reattach screen doors first and then fix light and try to indent the nodes to make the node above the selected node as parent. The above logic fails, as We are using previous sibling property to node[0] that is why it takes the previous sibling of first selected node not the first node in the selection.