You found a bug! We've classified it as
a bug in our system.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.[5.1] store record not marked as dirty
[5.1] store record not marked as dirty
We have a file upload form that takes a csv which is transformed by the server to a json response including the original data as well as the new one from the csv.
The goal is to show a grid with only changed records that can be each saved to the server with an actioncolumn.
We have this twice, one for devices which is working fine and another one for device entities where the records aren't marked dirty although the litte red marker is shown for the fk_service_contract column for the records that really changed.Code:
Ext5.define('NAC.model.DeviceEntity', {
extend: 'Ext5.data.Model',
alias: 'model.device_entity',
schema: 'nac',
idProperty: 'id_device_entity',
fields: [
{name:'id_device_entity', type:'int'},
{name:'devicename'},
{name:'name'},
{name:'description'},
{name:'class', type:'int'},
{name:'serial'},
{name:'modelname'},
{name:'fk_service_contract', type:'int'},
'messages'
]
});
var deviceEntityStore = Ext5.create('Ext5.data.Store', {
model: 'NAC.model.DeviceEntity',
filters: [
// only display modified records or with messages
function(record) {
console.log(record.dirty);
return record.dirty || record.get('messages');
}
]
});
form.submit({
success: function(fp, o){
var json_data = Ext.decode(o.response.responseText);
deviceEntityStore.loadData(json_data.device_entities);
// update using data from csv
deviceEntityStore.beginUpdate();
// clear all maintenance specific columns for all
// records
deviceEntityStore.each( function(record) {
// 1 = NO
record.set('fk_service_contract', 1);
});
// then set each from the csv data
Ext5.Array.each( json_data.device_entities_from_csv,
function(item) {
var record = deviceEntityStore.getById(item.id_device_entity);
if ( Ext5.isEmpty(record) ) {
console.log('device entity id ' + item.id_device_entity + ' not found');
return;
}
record.beginEdit();
record.set('fk_service_contract', item.fk_service_contract);
record.set('record_number', item.record_number, { dirty: false });
var messages = record.messages;
if ( Ext5.isDefined(item.messages) ) {
messages += ' ' + item.messages;
}
record.set('messages', messages, { dirty: false });
record.endEdit();
});
// TODO: deactivate fk_service_contract for all records not included in csv
// maybe by adding a column to the sort which remembers if the record has already been processed
deviceEntityStore.endUpdate();
}
});
[OPEN] [5.1] store record not marked as dirty
Aucun commentaire:
Enregistrer un commentaire