트리를 새로 고치는 방법을 찾았습니다. 모든 것이 잘 작동합니다. 하지만 이제는 특정 노드에 초점을 맞추기를 원하며 항상 _itemNodesMap이 정의되지 않았다고 말합니다. 포커싱dijit.Tree refresh 및 focusNode
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이 정의되지 얻을 여기
내가 가진 것입니다. 왜? 트리가 표시되고 경로가 설정되며이 경로 이외의 모든 경로가 작동합니다. 좀 도와 줘서 대단 하시겠습니까? 감사!
답장을 보내 주셔서 감사합니다. 지연을 사용하지 않고 this.set ('path', path);로 경로를 설정했습니다. – Sezunna
코드를 사용하면 동일한 문제가 발생합니다. myTree.path (또는 내 경우에는 this.path [path.lenght-1])는 정의되지 않습니다. 보기의 경로가 나중에 올바르게 설정 되더라도. 지연 사용을 시도해야합니까? (전에 그렇게하지 않았기 때문에 나는 조금 미숙하다.) – Sezunna
함수 호출은 다음과 같다 : dijit.byId ("myTree"). reload (data, path); dijit.byId ("myTree"). scroll (path); – Sezunna