View Full Version : Extract data from store and reload at later stage.

6 Dec 2013, 12:01 AM

I want to implement some autosave functionality on my screen. Something similar to that of Excel or MSWord where in the background all changes are being written to a temp file. So that if something happens on the screen (eg. Loss of Internet connection or accidentally closing the screen without saving) they will have the ability to recover the screen data.

I have most the screen working but I also have a grid on this screen which has AutoSync turned off so there is a store with multiple records which may be dirty.

So my question is :- Is there a way to take a snapshot of data from a store. Serialize that away somewhere and then reinstate it back into the grid so that is exactly the same as when the snapshot was taken?

Thanks for any help

6 Dec 2013, 12:20 AM
see this example:

var data;
var store = Ext.create('Ext.data.Store', {
data: [
{ 'name': 'Lisa' },
{ 'name': 'Bart' },
{ 'name': 'Homer' },
{ 'name': 'Marge' }

Ext.create('Ext.grid.Panel', {
store: store,
columns: [ { text: 'Name', dataIndex: 'name', flex: 1, editor: { xtype: 'textfield' } } ],
height: 200,
width: 400,
renderTo: Ext.getBody(),
plugins: Ext.create('Ext.grid.plugin.RowEditing', { }),
{xtype: 'button', text: 'Save', handler: saveHandler },
{xtype: 'button', text: 'Reload', handler: reloadHandler }

function saveHandler()
data = store.getRange();

function reloadHandler()

if you are able to save the records and then reload them from your backend, it should work. here if you edit a record and then Save, it saves them in the data variable and then when Reload is clicked, the data is loaded back into the store. the edited record is in same state as before.

the data wont be lost unless the browser is closed (internet connectivity loss will still leave the browser open with the last changes the user had made; he just wont be able to save). you can may be put an confirmation message so that if the user closes the browser tab or window, it asks for confirmation.

6 Dec 2013, 3:17 AM
Perfect...thank you!