extjs store ajax同步加载数据

extjs store ajax支持同步加载数据
 Ext.define('Ext.ux.data.proxy.Ajax', { 
        extend: 'Ext.data.proxy.Ajax', 
        async:true, 
        doRequest: function(operation, callback, scope) { 
            var writer  = this.getWriter(), 
                request = this.buildRequest(operation);   
            if (operation.allowWrite()) { 
                request = writer.write(request); 
            } 
            Ext.apply(request, { 
                async         : this.async, 
                binary        : this.binary, 
                headers       : this.headers, 
                timeout       : this.timeout, 
                scope         : this, 
                callback      : this.createRequestCallback(request, operation, callback, scope), 
                method        : this.getMethod(request), 
                disableCaching: false  
            }); 
            Ext.Ajax.request(request); 
            return request; 
        } 
    }); 
 
 
 使用的时候:
 proxy: Ext.create("Ext.ux.data.proxy.Ajax",{ 
  async:false, 
  url:"data/SystemMenus.json", 
  reader: { 
   type: 'json', 
   root: 'children', 
   idProperty: 'id' 
  } 
 })

Ext.define('syscodecol', {
   extend: 'Ext.data.Model',
   fields: ['coldesc','colcode','coldesci18n']
  });
  // 显示列store
  var col_store = Ext.create('Ext.data.Store', {
    model: 'syscodecol',
    proxy: Ext.create("Ext.ux.data.proxy.Ajax",{ 
                 async:false, 
                 url: SRM_CONTEXT+"/mdm/core/syscodecol!selectSyscodecolInfoByCond.action",
                 extraParams: 'cond.syscode':args.selectsyscode,'cond.enableflag':'1','cond.linkcolflag':'1','cond.pageI18n':pageI18n},
                 reader: {
       type: 'json',
       root: "syscodecolInfos"
      }
    }),
    autoLoad:true
  });

猜你喜欢

转载自blog.csdn.net/Alex_81D/article/details/84840620