我试图循环一个嵌套的json数组,以在网格单元格中显示值(使用extjs6.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-Grid&p=822648&viewfull=1#post822648
发布于 2015-08-21 17:35:54
如果要在单元格中显示特定内容,则需要实现渲染器。在呈现器函数中,您将迭代当前行的参与者,根据您希望该单元格的样子构建并返回HTML字符串。
https://stackoverflow.com/questions/32128148
复制相似问题