1. #1
    Sencha User
    Join Date
    Nov 2013
    Posts
    6
    Vote Rating
    0
    Rech is on a distinguished road

      0  

    Default Reloading data and refreshing grid in EXtJs4

    Reloading data and refreshing grid in EXtJs4


    I have a store and a grid in which I display the results. At some point I add an entry to my database, which works just fine. In fact, if I reload the page I see the newly added record in my grid. What I want to do is reload the grid so when I save that entry into my database the store and the grid refresh themselves and display the newly added record without me having to reload the whole page again.

    Any help is appreciated.

    Thanks.

  2. #2
    Sencha Premium Member tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,684
    Vote Rating
    112
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  

    Default


    instead of reloading the page, you can always just reload the store of the grid.

    noticing that something changed inside the DB is the more challenging part. you could use long polling to frequently check if something new is there or the cleaner way use a websocket (not there out of the box).
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

  3. #3
    Sencha User
    Join Date
    Sep 2013
    Location
    Cuba
    Posts
    26
    Vote Rating
    2
    Neopulse is on a distinguished road

      0  

    Default You can try something like

    You can try something like


    //The grid
    Ext.define('ControLab.view.gridVisita', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.gridVisita',
    store: 'storeVisita',
    ......
    //latter in some action you want to reload the grid
    ....
    var v_store = Ext.getStore('storeVisita'); //Get the store you associated to the grid
    v_store.load() //reoad the store
    ......
    Some time you make an action (write in a database or so) and need lets pass some time to reload the grid
    in that case try
    setTimeout(function(){v_store.load()},500);

  4. #4
    Sencha User
    Join Date
    Nov 2013
    Posts
    6
    Vote Rating
    0
    Rech is on a distinguished road

      0  

    Default


    I finally used TaskRunner, but now I have another problem. In my grid I double-click to edit my form. I change values​​ and I click on the Save button. Sometimes the change in the grid is taken into account and sometimes not.
    Here after the update function :
    Code:
    updateUser: function(button) {
                var win    = button.up('window'),
                form   = win.down('form'),
                record = form.getRecord(),
                values = form.getValues();
                var viewEF = form.getForm();
            if (viewEF.isValid()) {
                record.set(values);
                win.close();
                this.getUserStore().sync(); 
            }
        }
    Any idea ?

Thread Participants: 2