【问题标题】:antd Default table design does not work with Select Options and Date Pickerantd Default table design does not work with Select Options and Date Picker
【发布时间】:2022-12-01 12:19:18
【问题描述】:

The antd tables work well with Input components. I have been using the editable cell example at https://ant.design/components/table#components-table-demo-edit-cell and it works well with undo / redo functionality.

The Select / Options and Date Picker components however do not have any documentation in the context of a table that's hooked up to a state. I have gotten the Options / Date Picker to work but when implementing undo / redo logic, it looks like their state does not by default update like the Input fields. If you Google this, it is a tricky part of React in general to get these components to update automatically with state changes in a Form.

Is there an example of an antd table with select or date picker that's hooked up to state information?

I got the Select / Option to work correctly visually e.g. default states load correctly, depending on selection color changes etc. I can manipulate the data as needed. Similarly, got the Date Picker to work. However, where I am stuck is automatically tying state changes to update the components. I can probably do some crazy stuff like force render but before going that route wanted to check if there is a cleaner / better antd way of doing this.

【问题讨论】:

    标签: reactjs antd


    【解决方案1】:

    I think you have to custom return to default Editable Cells like the following example url example

    【讨论】:

    • Thanks for the help. The example does not work though - the render function also does not operate that way.
    【解决方案2】:

    After wasting many hours on this, it looks like there is a bug in antd Forms. See this SO thread: React | Ant design select value not setting

    In short, removed the Form.Item and everything works fine.

    【讨论】:

      猜你喜欢
      • 2022-12-13
      • 2016-12-29
      • 1970-01-01
      • 2021-06-14
      • 1970-01-01
      • 1970-01-01
      • 2021-10-02
      • 2022-11-24
      • 2021-11-04
      相关资源
      最近更新 更多