Hi,
I have a model called Event that hasMany Comment records. I have a store of Events. When I load the Events store everything is great. But if I make a server-side change and then call Ext.getStore('Events').load() it only reloads the 'first level' of the Event model. I need it to reload the data of the associated models as well. The proxy is only on the Events store, by the way.
In event details page/container:
Code:
this.getAt(0).getAt(0).setStore(record.photos());
this.getAt(0).getAt(1).setStore(record.videos());
this.getAt(6).getAt(1).setStore(record.comments());
Events model:
Code:
Ext.define('WSI.model.Event', {
extend: 'Ext.data.Model',
requires: ['WSI.model.Photo', 'WSI.model.Video', 'WSI.model.Comment'],
config: {
fields: [
{
name: 'id',
type: 'string'
}, {
name: 'title',
type: 'string'
}, {
name: 'description',
type: 'string'
}, {
name: 'category',
type: 'string'
}, {
name: 'dateTimeStart',
type: 'string'
}, {
name: 'dateTimeEnd',
type: 'string'
}, {
name: 'locationName',
type: 'string'
}, {
name: 'locationVicinity',
type: 'string'
}, {
name: 'locationLat',
type: 'string'
}, {
name: 'locationLng',
type: 'string'
}, {
name: 'viewCount',
type: 'number'
}, {
name: 'bookmarked_by_me',
type: 'boolean',
defaultValue: false
}, {
name: 'flagged_by_me',
type: 'boolean',
defaultValue: false
}
],
hasMany: [
{
associatedModel: 'WSI.model.Photo'
}, {
associatedModel: 'WSI.model.Video'
}, {
associatedModel: 'WSI.model.Comment'
}
]
}
});
Comment Model:
Code:
Ext.define('WSI.model.Comment', {
extend: 'Ext.data.Model',
config: {
fields: [
{
name: 'id',
type: 'string'
}, {
name: 'event_id',
type: 'string'
}, {
name: 'text',
type: 'string'
}, {
name: 'author',
type: 'string'
}, {
name: 'viewCount',
type: 'int'
}, {
name: 'flagCount',
type: 'int'
}, {
name: 'mobileOrigin',
type: 'int'
}, {
name: 'timestampCreated',
type: 'string'
}
]
}
});
Events Store:
Code:
Ext.define('WSI.store.Events', {
extend: 'Ext.data.Store',
xtype: 'eventsstore',
requires: ['WSI.model.Event'],
config: {
model: 'WSI.model.Event',
pageSize: 15,
autoLoad: false,
proxy: {
type: 'ajax',
url: 'REMOVED',
extraParams: {
sort: 'today',
category: 'all'
},
reader: {
type: 'json',
rootProperty: 'events'
}
}
}
});
"Refresh All" function in main controller:
Code:
refreshAll: function() {
return Ext.getStore('Events').load({
scope: this,
callback: function(records, operation, success) {
if (success) {
if (this.getEventDetailsContainer() != null) {
return this.onViewEventCommand(null, this.getEventDetailsContainer().getEventRecord());
}
}
}
});
}