How to get a store which is bound and filterd a viewModel.hasMany relationship synced?
I do have two grid panels in extjs5. say the first grid is groups and the second users. I bound the groups grid to viewModel stores.groups. This groups store is working and also syncing through the the models proxy (model is bound in the viewModel). The second grid is bound to the same viewModel through bind:{groupsReference.selection.users}
. The binding works. On selection of a group the users are filtered. Changing some User data marks the user record as dirty.
The Problem: Dirty Users are not autoSynced any more, nor am I able to figure out how to sync it manually. How can I get autoSynced working here? How can I trigger a manual sync?
The models for groups for users are identical except the hasMany/belongsTo relationship:
Ext.define('MyApp.model.Groups', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int' },
{ name: 'groupname', type: 'auto' }
],
autoLoad: true,
autoSync: true,
proxy: {
type: 'rest',
url: '/api/groups',
reader: {
type: 'json',
rootProperty: 'data',
successProperty: 'success'
},
writer: {
type: 'json'
}
},
hasMany: {
model: 'MyApp.model.Users',
store:'MyApp.model.Users',
name: 'users',
foreignKey:'testId',
}
});
And the view Model
Ext.define('MyApp.view.main.MainModel', {
extend: 'Ext.app.ViewModel',
requires: ['MyApp.model.Groups','MyApp.model.Users'],
alias: 'viewmodel.main',
stores: {
groups: {
model: 'mfct.model.Experiment',
autoLoad:true,
autoSync:true
},
users: {
model: 'mfct.model.Variation',
autoLoad:true,
autoSync:true
}
}
});