thanks for you reply,
console.log(store.getUpdatedRecords()); returns my record, which I have modified.
I don't have an id property, because if there is no explicit ID field, there will be one created. Now I have tried it with an id property, but there's no change.
But I think I know whats happening:
My Grid's model:
Code:
Ext.define('ConfDemo.model.GUI_CLASS', {
extend: 'Ext.data.Model',
uses: [
'ConfDemo.model.CLASS_DATA',
'ConfDemo.model.CLA_CH_AT'
],
fields: [
{
name: 'CLASS'
},
{
name: 'DESCRIPTION'
}
],
idProperty:'CLASS',
hasOne: {
associationKey: 'CLASS_DATA',
model: 'ConfDemo.model.CLASS_DATA'
},
hasMany: {
associationKey: 'CLA_CH_AT',
model: 'ConfDemo.model.CLA_CH_AT',
primaryKey: 'CHARACT',
name: 'characteristics'
}
});
And my model, where I want to set some fields.
Code:
Ext.define('ConfDemo.model.CLA_CH_AT', { extend: 'Ext.data.Model',
uses: [
'ConfDemo.model.GUI_CLASS'
],
fields: [
{
name: 'CHARACT'
},
{
name: 'DESCR'
},
{
name: 'ENTRY_REQ'
},
{
name: 'TYPE'
}
],
idProperty:'CHARACT',
belongsTo: {
model: 'ConfDemo.model.GUI_CLASS'
}
});
when I check getUpdatedRecords() on the sub-store, I find the changed record. But if I to the same on the grid's store, which only displays the first level of my nested store, it doesn't find any changed records.
I think, the getUpdatedRecords() method only looks for changes in the current level and not in sub-models (hasMany associations).
Am I correct?
I try to set the new value:
Code:
onLM_CharactConfigChange : function(combobox, newValue, oldValue, eOpts) {
var gpanel = combobox.up('fp_layoutmanagement').down('gridpanel[name=gp_class_config]');
var griditem = gpanel.getSelectionModel().getSelection();
var store = griditem[0].characteristics();
var record = store.getAt(store.findExact('CHARACT', combobox.name));
record.set('TYPE', newValue);
console.log(store.getUpdatedRecords()); //returns [record]
},
and in the save-button-event I want to write the whole store back to the server:
Code:
var gpanel = item.up('fp_layoutmanagement').down('gridpanel[name=gp_class_config]');
var store = gpanel.getStore();
var modifyrec = store.getModifiedRecords(); // in the consolelog: []
var updatedrec = store.getUpdatedRecords(); // in the consolelog: []
store.sync({
callback : function(batch, options) {
console.log(batch);
},
failure : function(batch, options) {
console.log(batch)
}
});
While writing this post, I came up with following solution:
When I set the griditem-record to dirty, then the getUpdatedRecords() will return the record and a write request is sent.
So I think there's no other way than setting all root-model elements to dirty, to force the whole store to be sent back to the server. Am I right?