我发现了如何刷新树并且一切正常。但现在我想专注于一个特定的节点,它总是说 _itemNodesMap 是未定义的。
这是我所拥有的:
require([
"dojo/_base/window", "dojo/data/ItemFileWriteStore",
"dijit/tree/ForestStoreModel", "dijit/Tree",
"dojo/domReady!"
], function(win, Ifrs, ForestStoreModel, Tree){
dojo.extend(Tree, {
reload: function (data, path) {
this.dndController.selectNone();
this.model.store.clearOnClose = true;
this.model.store.close();
this._itemNodesMap = {};
this.rootNode.state = "UNCHECKED";
this.model.root.children = null;
this.rootNode.destroyRecursive();
var _data = {identifier: "id", label: "label", items: data};
var _store = new Ifrs({data:_data});
var _treeModel = new ForestStoreModel({
store: _store,
rootId:"root",
rootLabel:"Things",
childrenAttr:["children"]
});
this.model.constructor(_treeModel);
this.postMixInProperties();
this._load();
path.unshift("root");
this.set('path',path);
}});
为了聚焦,我尝试添加以下内容并在设置路径后调用它:
scroll : function(path){
var itemnode = this._itemNodesMap[path[path.length-1]];
this.focusNode(itemnode[0]);
}
但我总是知道 _itemNodesMap 是未定义的。为什么?显示树,设置路径,除此之外的一切都有效。能得到一些帮助会很棒。谢谢!