Reputation: 319
I have a table in my database. I am adding the rows to a datastore created.
var journal_db = [];
var db;
This is my dataStore:
Ext.define('iPolis.store.journalStore', {
extend: 'Ext.data.Store',
requires: 'Ext.DateExtras',
config: {
model: 'iPolis.model.journal',
data : journal_db
}
});
I am adding the rows to my datastore like this:
for (var i=0; i < results.rows.length; i++){
row = results.rows.item(i);
journalStore.add({'id':row['id'],'infoLine':row['infoLine'],'eventDate':row['eventDate'],'address':row['address'],'text':row['text'],'place':row['place']});
}
It gives me a reference error Uncaught ReferenceError: journalStore is not defined. Can anyone please help me to add the rows to the datastore?
Upvotes: 0
Views: 255
Reputation: 6683
you need to create instance of store just before using it
var journalStore = Ext.create('iPolis.store.journalStore');
for (var i=0; i < results.rows.length; i++) {
journalStore.add(results.rows.item(i));
}
Upvotes: 1
Reputation: 6365
Here, Sencha Touch understands journalStore
as a variable. I cannot see it anywhere...so maybe it's really undefined.
To obtain your Store, simply add an id to your store definition, like: id: 'journal-store'
and whenever you want to get it, simply use Ext.getStore('journal-store')
.
Hope it helps.
PS: If your Store is not created automatically (through the config of other components, such as Ext.List), you have to explicitly create it. Add
journalStore = Ext.create('iPolis.store.journalStore');
and it should work.
Upvotes: 0