reactjs - Is it possible to add a row of Input controls to Ant table for searching purposes. Please refer the Image attached
问题描述
I want to add a row of inputs(text inputs,dropdowns) for filtering purposes right below the column header row in a antd table.Please refer the attached image.Is it possible to do ?
解决方案
我不知道您如何处理您的数据,但如果您只需要输入,我发现了两种可能性:
- 您可以将 JSX 传递给
title
标头数组的属性:
{
title: <div>Notes<br /><input type='text' /></div>,
dataIndex: 'note',
width: 100,
},
在这里我传递了一个输入,但您可以制作一个自定义组件来接受您想要过滤的数据片段。
- 您可以添加一行,其中每个列都包含输入(将数据作为道具传递的自定义组件):
{
key:0,
date: <input type='text' />,
amount: <input type='text' />,
type: <input type='text' />,
note: <input type='text' />,
},
我认为第二个更容易设置。假设您的数据来自 API 调用,它们在data
您用于在表中显示数据的数组之外可用。因此,您可以对其进行过滤,以将您想要的任何内容作为道具传递并在您的自定义输入/选择组件中对其进行管理。
这听起来像复制数据,但我想不出另一种方法来做到这一点。
推荐阅读
- github - 如何将包直接从 github 添加到 Julia?
- python - 如何使用 Beautifulsoup 提取没有标签的 HTML 文本?
- machine-learning - 基于协作过滤器的推荐系统的交叉验证
- c++ - 未调用模板方法重载
- amazon-web-services - 在 Quicksight 计算字段中,如果“午餐”=“午餐”,我如何为每个“天”的“用户名”字段执行 distinct_countif
- javascript - 使用 React 和 Node 问题构建 Shopify 应用程序
- c++ - 有什么方法可以检查模板类在 C++14 中是否具有嵌套类定义(或 typedef)?
- java - Java 流,不能从 Optional 转换
转为布尔值 - http - 来自 netcat 的 Web 响应中的最后一个数字
- python - 根据参考列表集分配熊猫列