【问题标题】:Extjs 4.1 - How to loadData from a Store to another StoreExtjs 4.1 - 如何将数据从商店加载到另一个商店
【发布时间】:2013-08-03 01:44:35
【问题描述】:

我有一个store1autoLoad:true

           store1 = Ext.create('Ext.data.Store', {
        fields: ['id', 'name'],
        autoLoad: true,
        proxy: {
            type: 'ajax',
            url: 'example.php',
            reader: {
                type: 'json',
                root: 'results'    // see json output                         
            }
        }
    });

我有一个带有 autoload:false 的网格有 store2

           store2 = Ext.create('Ext.data.Store', {
        fields: ['id', 'name'],
        autoLoad: false,
        proxy: {
            type: 'ajax',
            url: 'example.php',
            reader: {
                type: 'json',
                root: 'results'    // see json output                         
            }
        }
    });

我不想再次加载 store2。我想像从 store1 获取一样

grid.store2.loadData(store1.data) // fail

但是怎么做呢,谢谢

【问题讨论】:

    标签: extjs extjs4.1


    【解决方案1】:

    您可以从商店的load 活动中受益,试试这样:

    store1.addListener('load', function(records, operation, success) {
       if(success) {
          var obj = new Object();
          obj.success = true;
          obj.results = records;
          grid.store2.loadData(obj);
       }
    });
    

    【讨论】:

    • 但是如何在没有功能的情况下获取记录(记录,操作,成功){ b/c 我的网格稍后会初始化 :(
    • 是的,我只是通过使用 getRange() 得到它,一切正常,谢谢:)
    【解决方案2】:

    您可以在代码之前添加。 sortOnLoad=false;

    grid.store2.sortOnLoad=false
    grid.store2.loadData(store1.data) // fail
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多