PDA

View Full Version : Question about TreeLoader and AsyncTreeNode



Mango_lier
18 Apr 2011, 9:38 AM
My server side code returns a properly formatted JSON response for the tree. However, for some child nodes, it returns "[]" empty array. In case of empty array, I would like to set the node to a leaf. After overriding the "processResponse()" and setting the node.leaf to true, the node visually does not change to a leaf?



processResponse : function(response, node, callback, scope){
var json = response.responseText;
try {
var o = response.responseData || Ext.decode(json);
node.beginUpdate();
if (o.length) {
for(var i = 0, len = o.length; i < len; i++){
var n = this.createNode(o[i]);
if(n){
node.appendChild(n);
}
}
}
else {
node.leaf = true;
}
node.endUpdate();
this.runCallback(callback, scope || node, [node]);
}catch(e){
this.handleFailure(response);
}
}