【问题标题】:how can i loop for store items i want in ExtJS XTemplate?如何在 ExtJS XTemplate 中循环存储我想要的存储项目?
【发布时间】:2014-10-28 00:21:48
【问题描述】:

我有一个包含所有项目数据的商店。它还包含可以具有多个值的数据。 我一直在寻找几个小时,找不到答案。也许我正在寻找错误的方式或错误的解决方案来解决这个问题。 所以我可以将它们分组或类似的东西,这样我就可以遍历我想要的数据???:

parents: [
  {name: 'parentName', type: 'string'},
  {name: 'parentLastName', type: 'string'},
  {name: 'parentAge', type: 'number'}
]

children: [
  {name: 'childName', type: 'string'},
  {name: 'childLastName', type: 'string'},
  {name: 'childAge', type: 'number'},
]

【问题讨论】:

    标签: extjs model store


    【解决方案1】:

    您的问题可以更详细一些。通常,您会通过代理将数据加载到您的商店并通过 StoreManager 访问它。因此,如果您的商店包含记录,您可以像这样遍历它们:

    var store = Ext.data.StoreManager.lookup('<my store ID>');
    // don't forget to store.load(); if autoload is false
    store.each(function(record,id){
        // Do something with each record
        console.log(record);
    });
    

    要从记录中获取字段,您可以这样做,例如:

    record.get('parentName');
    

    希望这会有所帮助。如果没有,请提供更多信息

    提姆

    【讨论】:

      猜你喜欢
      • 2012-01-27
      • 2015-02-15
      • 1970-01-01
      • 2012-06-05
      • 1970-01-01
      • 2014-01-18
      • 2019-10-06
      • 2015-03-04
      • 1970-01-01
      相关资源
      最近更新 更多