-
29 Jul 2008 2:34 AM #1
Add new AsyncTreeNode and show it
Add new AsyncTreeNode and show it
Hi
I'm having a problem with adding AsyncTreeNode into a TreePanel.
Process goes like this ...
I have a node in a tree (which is shown like a leaf) and I want to add a subnode to it.
I do that with Ajax.request and record is inserted. Then I would like to refresh current node to show me sub nodes.
when I make a call currentNode.reload() I get "currentNode.reload() is not a function"
I've been surfing these forums and I don't have a single clue of what the hack is wrong ...
PHP Code:
tree.on('some event ',
function(node,e){
Ext.Ajax.request(
{
url : '/add_new_node/'+node.id,
success : function(response,result){
this.reload();
},
failure : function(response,result){ // failure code
},
scope: node
}
);
}
}
-
29 Jul 2008 2:43 AM #2
-
29 Jul 2008 3:27 AM #3
[FIXED]
[FIXED]
this is my new Ajax request and now it's working
I had to realod parentNode of my current node, so my currentNode is not leaf anymore ..
then find my node (with ID) in the relaoded nodes tree.findNodeById(nodeID); since references change (if I know anything about what's going on) to get my current node back .. and after that reload my currentNode and it works like a charm ...
PHP Code:
Ext.Ajax.request(
{
url : '/admin_extjs/actions/add_new_node/'+node.id,
success : function(response,result){
this.parentNode.addListener(
'load',
function(parentNode) {
var tree = parentNode.getOwnerTree();
var newNode = tree.getNodeById(node.id);
newNode.reload();
}
);
this.parentNode.reload();
},
failure : function(response,result){
var message = Ext.util.JSON.decode(result.responseText);
Ext.MessageBox.alert('Error', message.data);
},
scope: node
}
);


Reply With Quote