I have a view containing 2 grids. The grids are backed by 2 models. The relationship between the 2 models is one to many(keyless association).
Models:
Ext.define('TestApp.model.association.Project', {
extend: Ext.data.Model,
fields: [
{
type: 'int',
name: 'id'
}, {
type: 'string',
name: 'project'
}, {
type: 'number',
name: 'allocation'
}, {
type: 'string',
name: 'comments'
}, {
type:'string',
name:'state'
}
]
});
Ext.define('TestApp.model.association.User', {
extend: Ext.data.Model,
fields: [{
type: 'int',
name: 'id'
}, {
type: 'string',
name: 'employee'
}, {
type: 'string',
name: 'location'
}, {
type: 'string',
name: 'department'
}, {
type: 'string',
name: 'manager'
}, {
type: 'number',
name: 'allocation'
}],
hasMany: [{
model: 'TestApp.model.association.Project',
// Note: use of 'role' is preferred over 'name'
role: 'projects',
// Define role for inverse association
inverse: {
role: 'user'
}
}]
});
After I edit one row from the child part, I set the parent record as dirty (dirty=true) and then I sync the store. After I do the necessary work on the server I send back the response. After I receive the response the dirty flag on the child part remains true.
When having no association, after receiving the response from the server, the dirty flag is clear automatically.
I've created a fiddle for more details.
How to clear the dirty flag from an association after an update?
Edit
I've updated the fiddle to better show my problem. Steps to reproduce:
- Select John Doe record from the top panel
- Select Apple from the bottom panel
- Edit allocation and comments column (row edit plugin available). Press Ok
- Press the Save button from the toolbar of the second grid
The request is sent to the server. The server respond with a json (the server response is hardcoded an will always be the same).
The client is unable to set the child record received in the response and clear the dirty flag.
Why is doing this? Is this a bug?
originalValue!=currentValue
,so in this case I think you must check after data is set into field then what is its originalValue. – Tejas