I am loading a treestore, getting the root node, then trying to iterate over the children. From what I observe, to seems to me that the tree is loaded into the store, I am able to get the root, when I expand the root in the console I am able to see children, but when I try to access the children from ExtJS I get errors.
Any help would be greatly appreciated. Thank you very much in advance.
var ts = this.getStore('QaireTreeStore');
console.log("--- ts:");
console.log(ts);
var p = ts.getProxy();
console.log("--- p:");
console.log(p);
p.extraParams = {};
p.setExtraParam('prgmCode','arg1');
p.setExtraParam('qaireCode','arg2');
ts.removeAll();
ts.load();
var rn = ts.getRootNode();
console.log("--- rn:");
console.log(rn);
console.log("--- isRoot");
console.log(rn.isRoot());
rn.eachChild(function(n) {
console.log('-- n:');
console.log(n);
});
console.log("--- firstChild:");
console.log(rn.firstChild);
console.log("--- childNodes:");
console.log(rn.childNodes);
console.log("--- getChildAt 0:");
console.log(rn.getChildAt(0));
under "--- rn:" I expanded "childNodes" and "constructor" to show the data is present. The output appears as:
--- ts: SrvyController.js:71
constructor {autoLoad: false, model: function, storeId: "QaireTreeStore", proxy: constructor, fields: Array[1]…}
SrvyController.js:72
--- p: SrvyController.js:76
constructor {type: "ajax", api: Object, reader: constructor, model: function, hasListeners: HasListeners…}
SrvyController.js:77
--- rn: SrvyController.js:89
constructor {phantom: false, internalId: "ext-record-1", raw: Object, data: Object, modified: Object…}
childNodes: Array[1]
0: constructor
childNodes: Array[9]
data: Object
dirty: false
editing: false
events: Object
firstChild: constructor
hasListeners: HasListeners
id: "IHA.model.QaireModel-48"
internalId: 48
lastChild: constructor
modified: Object
nextSibling: null
parentNode: constructor
phantom: false
previousSibling: null
raw: Object
stores: Array[0]
proto: TemplateClass
length: 1
proto: Array[0]
data: Object
dirty: false
editing: false
events: Object
firstChild: constructor
hasListeners: HasListeners
id: "IHA.model.QaireModel-ext-record-1"
internalId: "ext-record-1"
lastChild: constructor
modified: Object
nextSibling: null
parentNode: null
phantom: false
previousSibling: null
raw: Object
stores: Array[0]
proto: TemplateClass
SrvyController.js:90
--- isRoot SrvyController.js:93
true SrvyController.js:94
--- firstChild: SrvyController.js:101
null SrvyController.js:102
--- childNodes: SrvyController.js:105
[] SrvyController.js:106
--- getChildAt 0: SrvyController.js:108
undefined