schmidetzki
11 Jun 2007, 12:01 PM
In some cases the callback is not called.
I changed the code of TreePanel.selectPath() (line 328) to the following and now the callback is called:
Ext.tree.TreePanel.prototype.selectPath = function(path, attr, callback){
attr = attr || "id";
var keys = path.split(this.pathSeparator);
var v = keys.pop();
if(keys.length > 0){
var f = function(success, node){
if(success && node){
var n = node.findChild(attr, v);
if(n){
n.select();
if(callback){
callback(true, n);
}
}
else callback(false, n); // please add this line to Ext !!
}else{
if(callback){
callback(false, n);
}
}
};
this.expandPath(keys.join(this.pathSeparator), attr, f);
}else{
this.root.select();
if(callback){
callback(true, this.root);
}
}
}
This seem to be a bug for me :-)
(Took me one houre plus to find out, why my callback wasn't called)
I try to reload the tree if selectPath fails to get fresh nodes from the server (someone else could have changed the data).
I try:
this.tree.selectPath(path, undefined, function(success){
console.log("selectPath callback");
if(!success){
console.log("path " + path + " not found")
this.reload(function(){
this.tree.selectPath(path, null, function(success){
if(!success)
console.log("after reload: still not found")
});
}.createDelegate(this));
}
else console.log("selected: ", path)
}.createDelegate(this))
May be there is an easyier way to do this ?
I changed the code of TreePanel.selectPath() (line 328) to the following and now the callback is called:
Ext.tree.TreePanel.prototype.selectPath = function(path, attr, callback){
attr = attr || "id";
var keys = path.split(this.pathSeparator);
var v = keys.pop();
if(keys.length > 0){
var f = function(success, node){
if(success && node){
var n = node.findChild(attr, v);
if(n){
n.select();
if(callback){
callback(true, n);
}
}
else callback(false, n); // please add this line to Ext !!
}else{
if(callback){
callback(false, n);
}
}
};
this.expandPath(keys.join(this.pathSeparator), attr, f);
}else{
this.root.select();
if(callback){
callback(true, this.root);
}
}
}
This seem to be a bug for me :-)
(Took me one houre plus to find out, why my callback wasn't called)
I try to reload the tree if selectPath fails to get fresh nodes from the server (someone else could have changed the data).
I try:
this.tree.selectPath(path, undefined, function(success){
console.log("selectPath callback");
if(!success){
console.log("path " + path + " not found")
this.reload(function(){
this.tree.selectPath(path, null, function(success){
if(!success)
console.log("after reload: still not found")
});
}.createDelegate(this));
}
else console.log("selected: ", path)
}.createDelegate(this))
May be there is an easyier way to do this ?