1. #1
    Sencha User
    Join Date
    Dec 2008
    Posts
    85
    Answers
    7
    Vote Rating
    0
    martinrame is on a distinguished road

      0  

    Default Answered: PagingGrid + JsonReader handling empty results

    Answered: PagingGrid + JsonReader handling empty results


    Hi, I'm using an Ext.grid.Panel with a verticalScrollerType: 'pagingridscroller" (aka Paging Grid) loaded from this JsonStore:

    Code:
    Ext.define('MyApp.store.Movimientos', {    
        extend: 'Ext.data.Store',
        requires: [
            'MyApp.model.Movimiento'
        ],
        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                pageSize: 100,
                remoteSort: true,
                remoteFilter: true,
                buffered: true,
                model: 'MyApp.model.Movimiento',
                proxy: {
                    type: 'ajax',
                    api: {
                        read: '/cgi-bin/tarjeta.cgi/movimientos/read'
                    },
                    reader: {
                        type: 'json',
                        idProperty: 'IDMOVIMIENTO',
                        totalProperty: 'total',
                        successProperty: 'success',
                        root: 'root'
                    },
                    simpleSortMode: true
            }, cfg)]);
        }
    });
    When the query I made on the server side have results, the grid is working ok, I mean, it initially shows the loadMask, then the data. But, when the query returns empty results, the loadMask stays forever.

    Here's an example of empty result:

    Code:
    { 
      "root" : [], 
      "success" : false, 
      "total" : 0 
    }
    What I'm doing wrong?. I would like the loadMask to dissapear, then see the empty grid.

    BTW: Using Extjs 4.1

  2. Try to return with success set to true instead of false.
    Code:
    { 
      "root" : [], 
    //  "success" : false,
      "success" : true, 
      "total" : 0 
    }

  3. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Try to return with success set to true instead of false.
    Code:
    { 
      "root" : [], 
    //  "success" : false,
      "success" : true, 
      "total" : 0 
    }

  4. #3
    Sencha User
    Join Date
    Dec 2008
    Posts
    85
    Answers
    7
    Vote Rating
    0
    martinrame is on a distinguished road

      0  

    Default


    Thanks vietits!, that did the trick.

    The answer raises a question, when should I use "success: false"?.

  5. #4
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    You should return "success": false when for some reason you couldn't do the action normally, such as missing parameters. In that case, you should supply a callback function to <store>.load() and then check the success argument to do the right thing.

  6. #5
    Sencha User
    Join Date
    Dec 2008
    Posts
    85
    Answers
    7
    Vote Rating
    0
    martinrame is on a distinguished road

      0  

    Default


    Thanks great answer.

Thread Participants: 1

Tags for this Thread

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..."