PDA

View Full Version : record.setDirty() before record.set(field, 'text') ?



JK4Sencha
28 Feb 2011, 7:10 AM
Hi there,
i had some problems during changing a field in a record which is in sync with the server. (store has listener update).
This is my listener from the Store

listeners:{
update:function(store, record, operation){
if(operation == Ext.data.Model.EDIT){
Ext.Ajax.request({
url : '...'
,params : { state : record.get('Status')}
,method: 'POST'
,success: function ( result, request ) {
if(!Ext.isEmpty(result.responseText)){
var jsonResp = Ext.decode(result.responseText);
if(jsonResp.error == true){
record.reject();
}
else{
record.commit();
}
var btnState = Ext.getCmp('btnState');
if(btnState != null){
btnState.setText('Status (' +
record.get('Status') + ')');
}
Ext.Msg.alert('Auftrag', jsonResp.message);
}
else{
location.href = '.';
}
},
failure: function ( result, request) {
location.href = '.';
}
});
}
}
}

and now when i call
record.set('Status', 'begin');
the property of the field should be changed. But when the Server throws an error. I want to reject the data from the record to the "old" ones. But that wasn't possible without calling before
record.setDirty(); .
However i think that the record is not marked as dirty when
record.set('Status', 'begin'); is called. And it doesn't know what was set before. Is this a bug or are there other solutions to do that?

Greetz Jonas