我想通过treePanel.expandPath展开到1001010000这一级,但现在用expandPath只能显示到1xxx这一级。请问是什么原因??
网上没有找到答案。都说treePanel.expandPath(/0000/1XXX/1001000000/1001010000,‘id’,function(){})是可以的。
我的tree是异步加载的。和这有关系吗??
我想通过treePanel.expandPath展开到1001010000这一级,但现在用expandPath只能显示到1xxx这一级。请问是什么原因??
网上没有找到答案。都说treePanel.expandPath(/0000/1XXX/1001000000/1001010000,‘id’,function(){})是可以的。
我的tree是异步加载的。和这有关系吗??
如果没有效果,那么expandPath肯定是只对已经加载的树有效果,异步的数据还没有下载下来,ext不会自动帮你加载其他未下载的数据的,你可以看这个函数的源代码,没有处理异步数据的。你可以自己添加callback,判断下是否有数据然后自己用同步的ajax加载数据
expandPath: function(path, field, separator, callback, scope) {
var me = this,
current = me.getRootNode(),
index = 1,
view = me.getView(),
keys,
expander;
field = field || me.getRootNode().idProperty;
separator = separator || '/';
if (Ext.isEmpty(path)) {
Ext.callback(callback, scope || me, [false, null]);
return;
}
keys = path.split(separator);
if (current.get(field) != keys[1]) {
// invalid root
Ext.callback(callback, scope || me, [false, current]);
return;
}
expander = function(){
if (++index === keys.length) {
Ext.callback(callback, scope || me, [true, current]);
return;
}
var node = current.findChild(field, keys[index]);
if (!node) {
Ext.callback(callback, scope || me, [false, current]);
return;
}
current = node;
current.expand(false, expander);
};
current.expand(false, expander);
}