Reputation: 7743
I am iterating over records in a store as they come in like so:
Ext.create('Ext.data.Store', {
model: 'Message',
storeId: 'Staging',
proxy: {
type: 'memory',
reader: {
type: 'json'
}
},
listeners: {
add: function(store, records, index, eOpts){
if (!Ext.data.StoreManager.lookup('Historical').isLoading()) {
this.each(function(item, index, count) {
if(item.notificationType === 'INBOX'){
// populate inbox store
// increment the unread inbox count
console.log('inbox');
} else if (item.notificationType === 'NOTIFICATION') {
// populate notifications store
// increment the unread notification count
}
});
// no historical data should be held in memory for performance
this.removeAll();
}
}
}
});
The item.notificationType property returns undefined.
I have tried other properties but they also return undefined.
I need to perform different actions when different types are encountered and thought this would do it!
So the item is a record in the store which contains json in the structure as follows:
{
"source":"2",
"target":"1416529",
"sourceType":"USER",
"redirectUrl":null,
"message":"cow's go...",
"id":606,
"targetType":"TEAM",
"messageType":"TIBRR_WALL_MESSAGE",
"notificationType":"INBOX",
"sentDate":1356599137173,
"parameters":null,
"targetId":"1416529",
"sourceId":"2",
"dispatched":true,
"read":false,
"readDate":null,
"dispatchedDate":1356599137377
}
Upvotes: 0
Views: 2832
Reputation: 30082
You haven't posted your model definition, so I'm assuming you have a field in your model with the name "notificationType".
In that case, you'll want to use the get method:
item.get('notificationType');
Upvotes: 1