gpt4 book ai didi

json - 无法使用 JSON 结果将数据呈现到网格列中

转载 作者:行者123 更新时间:2023-12-04 21:02:25 24 4
gpt4 key购买 nike

我有一个类似这样的网格商店。

var gridStore = Ext.create('Ext.data.Store',{
proxy : {
type : 'ajax',
actionMethods : {
read : 'POST'
},
url : 'getECIAgentWrapperJobs.do',
reader : {
type : 'json',
rootProperty : 'rows',
totalProperty : 'results'
}
},
pageSize : 3,
autoLoad : {start: 0, limit: 3}
});

显然,它向 url 发出了 AJAX 请求。
我为这家商店获得的 JSON 响应如下所示:
{  
"results":2,
"rows":[
{
"pkTable1":1,
"name":"Rick",
"eciAgentJob":{
"pkTable2":11,
"name":"Play Local Ar",
},
}
],
"msg":null,
"success":true,
}

现在这是我的网格的样子:
var mappedEciAgentJobsGrids = Ext.create('Ext.grid.Panel',{
store : gridStore,
columns : [
{
dataIndex : 'pkTable1',
header : 'Pk of table 1'
},
{
dataIndex : 'name',
header : 'Name'
},
{
dataIndex : 'eciAgentJob.pkTable2',
header : 'Pk of Table 2'
}
]
});

现在在我的 UI 中,前 2 列(分别带有 dataIndex: pkTable2 和 name)加载正常。但是对于第 3 个,它没有。
我知道这是因为我将 dataIndex 用作“eciAgentJob.pkTable2”。但是,当我们得到像我得到的那样的响应时,在列中加载数据的方式是什么(其中 eciAgentJob 是原始 JSON 中的一个对象)。
请帮忙。

编辑:由于其他一些用例原因,我不想使用渲染器。

最佳答案

在您的模型中定义一个新字段并使用所需字段进行映射。在转换函数中从记录中选择任何值。

 Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{ name: 'name', type: 'string ' },
{
name: 'columnName',

convert: function (value, record) {
return "return what ever you want"
}
}

]
});

关于json - 无法使用 JSON 结果将数据呈现到网格列中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56717427/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com