gpt4 book ai didi

javascript - 如何将动态列和行数据推送到antd表

转载 作者:行者123 更新时间:2023-12-04 13:51:52 25 4
gpt4 key购买 nike

enter image description here
以下代码不接受行和列数组
这是 antd 示例:

const data = [];
for (let i = 0; i < 4; i++) {
data.push({
key: i,
name: `Edward King ${i}`,
age: 32
// address: `London, Park Lane no. ${i}`
});
}

Tried same logic in below:
// columns :datacloumns1
// rows :rowdata

const data = [];
for (let i = 0; i < 4; i++) {
for (var j = 0; j < reportDataRows?.length; j++){
data.push({
datacloumns1[i]:rowdata[i] // here i am binding row to the exact column but this is not accepting
});
}
}

最佳答案

谢谢你的建议
这里的解决方案:将我的结果更改为 title 和 dataIIndex 格式,所以我意识到 antd 表只接受 title 和 dataIIndex 格式
让 datacloumns = reportDataRows && Object.keys(reportDataRows[0])?.map((key) => (
{cloumns.push({
标题:键,数据索引:键,
//defaultSortOrder: '降序',
分拣机:真的
})}
))

< Table rowClassName = {(record, index) => index % 2 === 0 ? 'table-row-light' : 'table-row-dark'} size = { 'default'} columns = { cloumns } bordered = { true} sortDirections = { ['ascend', 'descend'] } loading = { reportDataRows === undefined ? true : false} pagination
= {{ pageSize: 10 }} dataSource = { reportDataRows === 未定义? [] : 报告数据行}/>

关于javascript - 如何将动态列和行数据推送到antd表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68625319/

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