0

My store is taking time to load.so that i want to display a loading indicator while loading store data.Is there any function to know the list store is completely loaded or not? Please help me..I was searching for this long time..

Here is my code:

Ext.Viewport.setMasked({
    xtype: 'loadmask',
    message: 'Loading'
});

Ext.define('MyApp.view.Myview1', 
{
    extend: 'Ext.Panel',
    requires: ['Ext.List', 'Ext.util.JSON'],

    config: {
        layout: 'hbox',
        items: [
            {
                xtype: 'panel',
                layout: 'fit',
                flex: 1,
                items: [
                    {
                        xtype: 'list',
                        itemTpl:
                            '<div class="myContent">' +
                            '<div>{name}</div>' +
                            '</div>',
                        store: 'MainStore',
                        disclosure: true,
                        store.on({
                            load: {
                                fn: function( store ) {
                                    Ext.Viewport.setMasked(false);
                                },
                                scope: this,
                                single: true
                            }
                        });
                        store.load();
                    }
                ]
            }
        ]
    }
});

My requirement is to display indicator while loading data from store and remove it after the list have all data from store.

Luís Cruz
  • 14,780
  • 16
  • 68
  • 100
almakki
  • 197
  • 2
  • 15

4 Answers4

0

You will have to bind load event to this store like below code

  Ext.Viewport.setMasked({
     xtype: 'loadmask',
     message: 'Loading'
   });

   store.on({
    load: {
         fn: function( store ) {
            Ext.Viewport.setMasked(false);
         },
         scope: this,
         single: true
    }
});

store.load();
Naresh Tank
  • 1,569
  • 10
  • 23
0

This one is simple, just like @Naresh Said

put load mask inside your function

  Ext.Viewport.setMasked({
            xtype: 'loadmask',
            message: 'Please Wait...'
        });

and disable loadmask after store loads

storectn.load({
                callback: function (records, operation, success, response) {
                    if (success==1) {
                       // Ext.Msg.alert('success');
                         Ext.Viewport.setMasked(false);
                    } else {
                       // Ext.Msg.alert('Failed');
                         Ext.Viewport.setMasked(false);


                    }
                }
            });
Dibish
  • 9,133
  • 22
  • 64
  • 106
0

Finally I have solved the problem :)

Sencha loads the store and list within a very short time but the UI takes long time to load. So, after finish loading the stores if you set a callback to remove indicator using setTimeout then the problem will be solved. Because when UI loading is finished it will call your final method, because JavaScript is a single thread language.

Ext.Viewport.setMasked({
     xtype: 'loadmask',
     message: 'Loading'
   });

   store.on({
    load: {
         fn: function( store ) {
            setTimeout(function(){
                Ext.Viewport.setMasked(false);
            }, 100);
         },
         scope: this,
         single: true
    }
});

store.load();

Here even though the setTimeout is supposed to be called after 100 milliseconds, it will wait for the UI to be loaded first and then be called.

If you are loading the store dynamically by a custom query with store.add(Record), then after loading all data you just call the setTimeout call. It will work as well.

SM Adnan
  • 555
  • 2
  • 10
0

We need to setmask(prevent user interaction and show loading message) while loading data in sencha touch. Sencha touch setMasked(<>) gives option to add mask into containers. But every time we need to manually add the mask and remove the mask. Instant of this manually doing things we can use store listeners.

My requirement here is i have a one store for CRUD process. So every time when i try to sync and loading the data’s i want to setmask of the view. My store code is like the below.

I used beforeload, beforesync, load, metachange, removerecords, updaterecord, write, addrecords events for this task.

Please visit the below url for full source code by clicking the link. [Solved by solution]

http://saravanakumar.org/blog/2014/04/sencha-touch-setmask-display-load-mask-or-waiting-while-loading-data-in-store/

saravanakumar
  • 103
  • 1
  • 1
  • 5