1. #1
    Sencha User
    Join Date
    Aug 2009
    Posts
    14
    Answers
    1
    Vote Rating
    1
    glenho is on a distinguished road

      0  

    Default Answered: Extract data from store and reload at later stage.

    Answered: Extract data from store and reload at later stage.


    Hi

    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
    Glen

  2. Perfect...thank you!

  3. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,084
    Answers
    112
    Vote Rating
    95
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      2  

    Default


    see this example:

    Code:
    var data;
    var store = Ext.create('Ext.data.Store', {
        fields:['name'],
        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', { }),
        bbar:
        [
            {xtype: 'button', text: 'Save', handler: saveHandler },
            {xtype: 'button', text: 'Reload', handler: reloadHandler }
        ]
    });
    
    function saveHandler()
    {
        data = store.getRange();
        store.loadData([]);
    }
    
    function reloadHandler()
    {
        store.loadData(data);
        console.log(store.getModifiedRecords());
    }
    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.

  4. #3
    Sencha User
    Join Date
    Aug 2009
    Posts
    14
    Answers
    1
    Vote Rating
    1
    glenho is on a distinguished road

      1  

    Default


    Perfect...thank you!

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi