ant-design / pro-table

🏆 Use Ant Design Table like a Pro!
https://protable.ant.design/
MIT License
562 stars 151 forks source link

Provides EditableTable which support form api #319

Open zombieJ opened 5 years ago

zombieJ commented 5 years ago

What problem does this feature solve?

Currently Table with editable is hard integrated with form api

What does the proposed API look like?

getFieldDecorator('records', { initialValue: [] })(
  <EditableTable />
);

update:

afc163 commented 5 years ago

这个组合太复杂了吧...

zombieJ commented 5 years ago

其实还行…… 主要就是处理 onChange 和 dataSource 的联动,因为我们有 dataIndex 正好可以复用了。现在自己包了一个 EditableTable:

tableColumns = [
    {
      title: 'Field 1',
      dataIndex: 'field_1',
      key: 'field_1',
      width: '30%',
      renderItem: <Input />,
    },
    {
      title: 'Field 2',
      dataIndex: 'field_2',
      key: 'field_2',
      width: '30%',
      renderItem: <Select style={{ width: '100%' }}>
        <Select.Option value="value_1">数值 1</Select.Option>
        <Select.Option value="value_2">数值 2</Select.Option>
      </Select>,
    },
];

getFieldDecorator('table_records', { initialValue: [] })(
  <EditableTable columns={this.tableColumns}  />
)
bobby1991qw commented 5 years ago

确实挺复杂的,我们现在也碰到这样的交互。一个表单里面有一个editableTable。变成form里面包了table,table里又包了form。而且在编辑的时候,某个column可能对应不止1个字段。比如地址:编辑的时候,要选择省市,填写详细地址,和选择地图经纬度。

paranoidjk commented 4 years ago

从云凤蝶这边接到业务需求反馈来看,这种形态的设计稿非常高频,我猜是因为这本质是就是在编辑后端的一对多的关联模型,而一对多在后端非常常见

zombieJ commented 4 years ago

Move to pro-table