繁体   English   中英

如何在extjs网格单元格中显示嵌套数组

[英]How to display nested array in extjs grid cell

我试图遍历嵌套的json数组以在网格单元中显示值(使用extjs 6.0)。

这是视图中的列:

{
    header: 'Participants',
    dataIndex: 'participants'   
},

该模型:

Ext.define('App.model.Event', {
    extend: 'Ext.data.Model',

    fields: [

        { name: 'eventTypeName', type: 'auto', mapping: 'eventType.eventType' },

        // this only grabs the first object in the list....how to grab all?
        { name: 'participants', type: 'auto', mapping: 'participants[0].participantName' },


    ]
});

和json:

{
  "_embedded" : {
    "events" : [ {
      "participants" : [ {
        "participantId" : 1,
        "participantName" : "name1"
      }, {
        "participantId" : 2,
        "participantName" : "name2"
      }, {
        "participantId" : 3,
        "participantName" : "name3"
      } ],

    }
  }
}

网格中的行是事件,每个事件行将有多个参与者要在单元格中显示。 如何在单个单元格中显示所有参与者名称?

我已经使用hasMany方法尝试了类似于此帖子的内容,但无济于事: https ://www.sencha.com/forum/showthread.php?205509-Displaying-a-hasMany-model-relationship-in-a- 网格和p值= 822648&viewfull = 1#post822648

如果要在单元格中显示特殊内容,则需要实现renderer 在renderer函数中,您将遍历参与者的当前行,根据所需单元格的外观构建并返回HTML字符串。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM