私はこのようなJSONを持っています。
{
"children":[
{"name": "subdivision1","id": "subdiv1","type": "subdiv","children":[
{"name": "Scheme1","id": "scheme1","type": "scheme","children":[
{"name": "Nathuji","id": "nathuji","type": "datalogger","leaf":true},
{ "name": "Tarsang","id": "tarsang","type": "datalogger","leaf":true},
{ "name": "Mithapur","id": "mithapur","type": "datalogger","leaf":true},
{ "name": "Samali","id": "samali","type": "datalogger","leaf":true}]},
{"name": "Scheme2","id": "scheme2","type": "scheme","children":[
{ "name": "Bhunidra","belongsto": "scheme2","id": "bhunidra","type": "datalogger","leaf":true},
{ "name": "Chhogala","belongsto": "scheme2","id": "chhogala","type": "datalogger","leaf":true}]
}]},
{"name": "subdivision2","id": "subdiv2","type": "subdiv","children":[
{"name": "Scheme3","id": "scheme3","type": "scheme","children":[
{ "name": "Thana Savli","belongsto": "scheme3","id": "thanasavli","type": "datalogger","leaf":true},
{ "name": "Padardi","belongsto": "scheme3","id": "padardi","type": "datalogger","leaf":true}]
}]}]}
このようなモデル。
Ext.define('DemoApp.model.dataloggerhierarchymodel',{
extend: 'Ext.data.Model',
fields: ['name','id','type'],
proxy: {
type: 'ajax',
api: {
read: 'data/allschemes.json'
},
reader: {
type: 'json',
root: 'children'
}
}
});
このように保管してください。
Ext.define('DemoApp.store.dataloggerhierarchystore',{
extend: 'Ext.data.TreeStore',
model: 'DemoApp.model.dataloggerhierarchymodel',
autoLoad: true,
listeners: {
load:function(){
console.log('Datalogger Tree store loaded');
}
},
root: {
expanded: true
}
});
私は次のようにコントローラーでアクセスしています。
var schemesStore = this.getDataloggerhierarchystoreStore();
if(schemesStore == null || schemesStore == undefined){
console.log('Store Undefined');
}
for(var i = 0; i< schemesStore.count();i++)
{
console.log('Record - '+schemesStore[i].get('id'));
};
schemesStore.each(function(currentRecord){
console.log(currentRecord.get('id'));
});
ツリーパネルに表示していますが、正常に動作します。次に、ストアから各レコードにアクセスします。しかし、エラーcount()
が発生しているのは関数ではありません。、の場合も同様totalCount()
ですeach()
。ここで何が欠けていますか?ストアから個々のレコードにアクセスするにはどうすればよいですか?