View Full Version : in store go back to previous state of record and not listing in modified records list

29 Jul 2009, 11:23 PM
I try to find trick way to detect "Is the grid go back to last loaded state?" to not list in modified records list.

I mean if you edit a cell and then re-edit the cell and go back to first state, we should not get this record as modified records list.

I need such a thing for that case:

If user clicks any other item (for example can be top menu cause user to be redirected) or user changes the card layout of the center panel, we are going to ask either save changes or not.

So we need some how to find is there any changes on center panel.

Has anybody faced with same problem?


29 Jul 2009, 11:31 PM

Best way is using AJAX on saving changes simultaneously.

But we may have dummy users, better way is putting a button to save changes.


5 Aug 2009, 1:27 AM
Any Comments?

5 Aug 2009, 1:33 AM
I don't think I understand the question...

Are you looking for the store methods: getModifiedRecords, commitChanges, rejectChanges?

5 Aug 2009, 5:52 AM
Dear Condor,

This is the situation:
I have editable grid, and I edit the some editable field and change the record.
Now we can get this record by getModifiedRecords (http://extjs.com/forum/../deploy/ext-3.0-rc1.1/docs/source/Store.html#method-Ext.data.Store-getModifiedRecords)() method of the store.

But then I re-editing the same record and come back to initially loaded state. For example in the grid change sequance like that:
"Ali" --> "Aliye" --> "Ali"

In that case when I call getModifiedRecords() method, again I get the same record.

I try to find a way that ignore these records in getModifiedRecords() method.
I need a generic solution because I use this method in many places.

Thanks for your response.

5 Aug 2009, 6:01 AM
Try this (untested):

Ext.override(Ext.data.Record, {
set : function(name, value){
var isObj = (typeof value === 'object');
if(!isObj && String(this.data[name]) === String(value)){
} else if (isObj && Ext.encode(this.data[name]) === Ext.encode(value)) {
this.dirty = true;
this.modified = {};
if(typeof this.modified[name] == 'undefined'){
this.modified[name] = this.data[name];
if(!isObj && String(this.modified[name]) === String(value)){
delete this.modified[name];
} else if (isObj && Ext.encode(this.modified[name]) === Ext.encode(value)) {
delete this.modified[name];
this.data[name] = value;
if(this.dirty = !!this.fields.find(function(f) {
return this.modified.hasOwnProperty(f.name);
}, this)){
delete this.modified();