我想在服务器响应之间加载本地存储(使java脚本代码同步)

I want to load local store in between the server response (making java script code synchronysed)

本文关键字:java 脚本 代码 同步 存储 服务器 响应 之间 加载      更新时间:2023-09-26

我有一个正在尝试显示所有组织的视图页面,它是通过服务器调用获得。。为了感受应用程序的响应,在我要加载所有本地存储的服务器响应之间项。。但服务器调用总是首先执行。。代码I如下所述。。

initialize: function() 
{
    var me = this,
    st = Ext.create("Ext.data.Store", {
         fields : [ {......................}]});
    me.callParent(arguments);  
    me.setStore(st);
    me.on({
        show  : me.onShow,              
        scope: me
        });   
},
onShow:function()
{
      var me = this;
      Ext.create('Ext.util.DelayedTask', 
      //call back function ,purpose : delayed exicution
          function () {
          me.DelShow(function(){
         _syncMgr.getOrgGroup(-1,0,5); // servercall
          });
          }).delay(500);
},  
DelShow: function(callback)
{
            orgStore = Ext.getStore('Organizations'),
            orgStore.load(function(records)
                {
                    var i=0,len = records.length,
                    for(;i<len;i++)
                    {
                        organization = records[i];
                        regId = organization.get('rg_id');
                        resStr = organization.Resources();                      
                        resStr.load({callback:function(resorces)
                         {
                            var i = 0,rlen =resorces.length,
                            obj = {},
                            obj.rg_id = str.boundTo.get('rg_id');
                        }
                           orgViStr.add([obj]);

                       });
                     }
                });
    me.lodorg(callback);
    },

lodorg:function(callback)
{
 callback();
 console.log("I don't know why this call back works first....");
 console.log("plz help me to work last....");     
}

从本地存储加载数据后调用回调方法。

您要做的是将本地商店中的内容添加到视图中当前设置的列表中,然后刷新列表。

var localStore = something.getStore(),
entries = [];
localStore.each(function(entry){
    entries.push(entry.copy);
});
//me is the list that is set in the view
me.add(entries);
me.deselectAll();
me.refresh();

希望能有所帮助:(