PDA

View Full Version : Help is needed in loading a store.



skyracer85
21 Feb 2014, 8:26 PM
Hi Team,
I am trying to load a category store from the quiz store. The quiz store will be loaded by default.(becuase it is auto load)

categories_store.loadData(quiz_store.getAt(0).items().data.items);

But I am getting the following error sometimes. If i refresh the screen it is working again.

[E] TypeError: Cannot call method 'items' of undefined ext-dev.js:12300 (http://localhost/Prediction/ext/ext-dev.js)

logext-dev.js:12300 (http://localhost/Prediction/ext/ext-dev.js)
Ext.define.onTickext-dev.js:14142 (http://localhost/Prediction/ext/ext-dev.js)
(anonymous function)


Regards,
Rajesh

scottmartin
22 Feb 2014, 9:14 AM
Are you using a debugger to check the values of your call?

What do you see for:


quiz_store.getAt(0).items()
quiz_store.getAt(0).items().data
quiz_store.getAt(0).items().data.items


Are you trying to access the data before it is loaded instead of access it on the load listener?


listeners : {
load : function (store, recs) {
var record = store.getAt(0); // or recs[0]
store.loadData([ record.getData() ], true);
}
}


It would be better to use the methods that are available instead of trying to access the object directly


var record = store.getAt(0); // get 1st record
store.loadData([ record.getData() ]); // load first record intro store; record array

skyracer85
3 Mar 2014, 7:25 PM
Hi Scot,
Thanks for the Solution.
As you said, The mistake is that I am trying to access the store before it gets loaded.
I have corrected it now. :)


Thanks.
Rajesh