我正在迭代商店中的记录,因为它们像这样进来:
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();
}
}
}
});
item.notificationType属性返回未定义。
我尝试了其他属性,但它们也返回未定义。
当遇到不同类型时我需要执行不同的操作并认为可以这样做!
所以 item 是 store 中的一条记录,它包含 json 的结构如下:
{
"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
}