PDA

View Full Version : Why the treenode appendChild no work?



enotsl
13 May 2009, 6:06 PM
The "oldParent.appendChild(node);" is not work,

but "oldParent.appendChild({nodeType:'async', text:name, cls:'x-nav-file', icon:icon, id:id, _id:_id, leaf:true})" can append a childnode, but have error



a is undefined
DomHelper()(Object browserEvent=Event resize button=-1 type=resize, undefined)ext-all.js

DomHelper()(Object browserEvent=Event resize button=-1 type=resize, div#extdd-43.x-tree-node-el)ext-all.js

C()



i had search the old post about this problem, but the resolvent is not work.

why, pls help me. thanks, my code is at below.



onBeforeMoveNode : function(tree, node, oldParent, newParent, index ){
var opath = node.id;
var npath = (newParent.id + '\/' + node.text).formatPath();
if(opath==npath) return false;
Ext.Ajax.request({
url: cfg.ajaxPath+'moveFile',
params: { opath: opath, npath: npath },
success: function(response,opt) {
if(!response.responseText){
node.id = npath;
}else{
Ext.Msg.alert('error', 'Have the same file name');
oldParent.appendChild(node);
newParent.removeChild(node);
}
}
});
},

Condor
13 May 2009, 10:57 PM
Calling appendChild automatically calls removeChild on the old parent, so you get an error if you try to do it a second time.

ps. An error from ext-all.js is totally useless. Use ext-all-debug.js for testing!