- grid = this;
- store = grid.getStore();
For New Records
var updatedRecords = this.getStore().getNewRecords();getNewRecords( ) : Ext.data.Model[]
Returns all Model instances that are either currently a phantom (e.g. have no id), or have an ID but have not yet been saved on this Store (this happens when adding a non-phantom record from another Store into this one)
For Updated Records
var updatedRecords = this.getStore().getUpdatedRecords();getUpdatedRecords( ) : Ext.data.Model[]
Returns all Model instances that have been updated in the Store but not yet synchronized with the Proxy
For Deleted Records
var updatedRecords = this.getStore().getRemovedRecords();getRemovedRecords( ) : Ext.data.Model[]
Returns any records that have been removed from the store but not yet destroyed on the proxy.
Tip: Please make sure that you specify the idProperty in the store's model.
If you forget to specify an idProperty then all records in the store will be considered New Records and when you try to get updated Records will get an empty List or your store sync will call the create api instead of update.
idProperty : String
The name of the field treated as this Model's unique id. Defaults to 'id'.
How to get the store's New/Updated records and create an Ajax Request
parms = []; var updatedRecords = this.getStore().getUpdatedRecords(); Ext.each(updatedRecords,function(record){ parms.push(record.data); }); var newRecords = this.getStore().getNewRecords(); Ext.each(newRecords,function(record){ parms.push(record.data); }); if(parms.length > 0){ this.el.mask('Saving Your Changes...'); Ext.Ajax.request({ url : '/MyAJAXRequest', params : { action: 'addUpdateRecords', records : Ext.encode(parms) }, scope : this, success : this.onSaveChangesSuccess, failure : this.onSaveChangesFailure }); }
No comments:
Post a Comment
NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.