admin管理员组文章数量:1391960
I'm using React + Ant.design and I need to make a table where each row will be a form with a number of inputs which are represents fields of this row and user can edit value in each field and push Save at the end of each row.
But I have no idea how to do it, because there is only datasource property in Table ponent for the plain data in JSON format.
const dataSource = [
{
id: 1,
name: 'Name 1',
number: 1,
username: 'user1',
date: '09-09-2011',
status: 'reviewed'
},
{
id: 2,
name: 'Name 2',
number: 2,
username: 'user2',
date: '01-10-2021',
status: 'reviewed'
}
]
<Table
size="small"
rowKey="id"
dataSource={dataSource} <-- row data here, need to have form with input for each field
columns={this.columns}
bordered={false}
rowClassName={(record, index) => {
return cssClasses.tableRow
}}
title={TableTitle}
>
Is it possible at all to have forms within table rows or it's better to make it using just React ponents?
I'm using React + Ant.design and I need to make a table where each row will be a form with a number of inputs which are represents fields of this row and user can edit value in each field and push Save at the end of each row.
But I have no idea how to do it, because there is only datasource property in Table ponent for the plain data in JSON format.
const dataSource = [
{
id: 1,
name: 'Name 1',
number: 1,
username: 'user1',
date: '09-09-2011',
status: 'reviewed'
},
{
id: 2,
name: 'Name 2',
number: 2,
username: 'user2',
date: '01-10-2021',
status: 'reviewed'
}
]
<Table
size="small"
rowKey="id"
dataSource={dataSource} <-- row data here, need to have form with input for each field
columns={this.columns}
bordered={false}
rowClassName={(record, index) => {
return cssClasses.tableRow
}}
title={TableTitle}
>
Is it possible at all to have forms within table rows or it's better to make it using just React ponents?
Share Improve this question edited Feb 20, 2018 at 9:31 Dmitry asked Feb 20, 2018 at 9:22 DmitryDmitry 8673 gold badges16 silver badges31 bronze badges2 Answers
Reset to default 0I'm not fully understand your problem
Do you mean the render callback from columns
props?
You can defined in columns props to render an input:
const column = [
{
title: 'input',
dataIndex: 'value',
render: (value, row, index) => { return <input /> } // just an example
}
]
for more info check this example:
https://ant.design/ponents/table/#ponents-table-demo-edit-row
Yes its possible...
your datasource should be in a state
you can do something like this
state = {dataSource: this.dataSource.map(data => {
return {
key: data.id,
item: (
<Select
<Option></Option>
</Select>
),
quantity: <InputNumber/>,
ments:<TextArea/>,
};
})}`
and you can replace this.dataSource
with this.state.dataSource
<Table
dataSource={this.state.dataSource}
/>
本文标签: javascriptIs it possible to insert form into each row in table using AntdesignStack Overflow
版权声明:本文标题:javascript - Is it possible to insert form into each row in table using Ant.design? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744738790a2622488.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论