[su_icon_text icon=”icon: info-circle” icon_color=”#5b63df” class=”saki-info-box”]Code in this post can be obsolete, however, principles and theory may still apply.[/su_icon_text] If you modify records of an editable grid with paging and if you then page-out, your changes are lost. Well, they are not lost in fact unless you have set
pruneModifiedRecords:true on the strore. The modifications are still available so we just need to apply them. Here is the code fragment that does it:
var grid = new Ext.grid.EditorGridPanel({
store:new Ext.data.Store({
listeners:{
load:{scope:this, fn:function(store) {
// loop through modified records
var modified = store.getModifiedRecords();
for(var i = 0; i < modified.length; i++) {
// see if we have a record with same id
// and apply changes if yes
var r = store.getById(modified[i].id);
if(r) {
var changes = modified[i].getChanges();
for(p in changes) {
if(changes.hasOwnProperty(p)) {
r.set(p, changes[p]);
}
} // eo changes loop
}
} // eo modified loop
}} // eo load listener
} // eo listeners
// rest of store configuration
})
// rest of grid configuration
}) // eo grid
pruneModifiedRecords must be false (the default) for this to work.
I'm a well seasoned developer, consultant and educator of web applications based mainly on Sencha libraries, PHP, MySQL and Node.js. Besides (Apple) computers, I love photography and mountain biking.
Follow me:
Latest posts by saki (see all)
- Ext, Angular, React, and Vue - 27. June 2019
- The Site Resurgence - 11. February 2018
- Configuring ViewModel Hierarchy - 19. June 2015