找出商店中有多少状态对象

Finding out how many status objects are in a store

我有一家名为 CreativeStore 的商店,其中一个字段是 Status。数据发送为 JSON。我创建了一个获取 Creative 商店的变量。我如何找出状态是什么以及它们有多少状态。
在我的创意模型中,我有一个字段

 }, {
    type: 'int',
    name: 'Status'
  }, {

在我的 View Controller 中,我有一个方法可以检查我为创意模型创建的商店是否存在(确实存在),并将其分配给一个名为 test 的变量。

var test = this.getCreativeStore();

  getCreativeStore: function () {
    var creativeStore = this.getStore('creativeStore');
    if (!creativeStore) {
      this.logError('creativeStore is undefined');
    }
    return creativeStore;
  }

如何找出变量 test 中有多少状态?

var statusCount = 0;

test.each(function(record) {
    // Your status value in myStatus
    if(record.get('Status') === myStatus)
        ++statusCount;
});

您可以使用 collect:

Collects unique values for a particular dataIndex from this store.

例如:

test.collect('status').length;