PDA

View Full Version : Issue in adding a new node



nandakumaran.k
4 Feb 2012, 6:30 AM
Hi ALL,
I am new to extjs. Working with extjs 4.0.2
Trying to add a new node to a node in two ways as given below:



var vnode = tree.getSelectionModel().getSelection();
var fnode = vnode[0];
//var animationNode = fnode.appendChild(new Ext.data.NodeInterface()); // appending this way works

var animationNode = new Ext.data.NodeInterface(); // This way of node creation is not working.
animationNode.set('text', 'ANIMAT');
animationNode.set('allowDrag', false);
animationNode.set('iconCls', 'icon-menu-animation');
animationNode.set('id', 'ANIMAT');
animationNode.set('qtip', 'Animation Node');
animationNode.set('leaf', 'true');
fnode.appendChild(animationNode);

Why creation of new node and then appending the node is not working.

mitchellsimoens
4 Feb 2012, 7:12 AM
I have used appendChild in 4.0.7 and 4.1.0 with no issues.

nandakumaran.k
4 Feb 2012, 8:35 AM
i Mitchellsimoens,

Thanks for the reply.

which method have you followed.


var vnode = tree.getSelectionModel().getSelection();
var fnode = vnode[0];

var animationNode = fnode.appendChild(new Ext.data.NodeInterface());
animationNode.set('text', 'ANIMAT');
animationNode.set('allowDrag', false);
animationNode.set('iconCls', 'icon-menu-animation');
animationNode.set('id', 'ANIMAT');


OR

(The below approach is not working)
var vnode = tree.getSelectionModel().getSelection();
var fnode = vnode[0];
var animationNode = new Ext.data.NodeInterface();
animationNode.set('text', 'ANIMAT');
animationNode.set('allowDrag', false);
animationNode.set('iconCls', 'icon-menu-animation');
animationNode.set('id', 'ANIMAT');
fnode.appendChild(animationNode);


If both the approach should work, then what is that I am missing in the second approach.