【问题标题】:Extjs 4.2 store.getRange gives data of previously loaded storeExtjs 4.2 store.getRange 提供先前加载的商店的数据
【发布时间】:2014-06-16 00:18:09
【问题描述】:

我有一个与网格类关联的 extjs 存储。当我选择一个类时,它会给出记录的 ClassID。

var ClassData = record.get('ClassID');
console.log(ClassData);

基于这个 ClassID 我正在加载下一个网格的存储:

var Grid = this.getSemGrid();
var Store = Grid.getStore();     // your grid's store    

//load store with records having selected class ID
var g = Store.load( {params : {ClassID: ClassData }});

到这里一切都很好。

加载商店后,我将获取所有加载的记录(错误区域

var selected = g.getRange();  // getRange = select all records

然后将所有记录的一个字段的所有值压入一个数组中

var Excerpt = []; // start with empty array
Ext.each(selected, function(item) {
    // add the fields that you want to include
    var Obj = {
        third_field: item.get('ExamName')
    };
    Excerpt.push(Obj); // push this to the array
}, this);
console.log(Excerpt);

Excerpt 给出了先前选择的记录数组,而不是当前记录。

我也试过了

Store.loadData([],false); 

在重新加载之前清除商店的所有加载数据。

【问题讨论】:

    标签: extjs


    【解决方案1】:

    搞定了

    var g = Store.load({ 
      params : {ClassID: ClassData }, 
      callback : function(records, operation, success){ 
        var Excerpt = []; // start with empty array 
        Ext.each(records, function(item) { 
          // add the fields that you want to include 
          var Obj = { 
            third_field: item.get('ExamName') 
          }; 
        Excerpt.push(Obj); // push this to the array 
        }, this); 
      } 
    }); 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-26
      • 2013-03-17
      • 2012-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多