简体   繁体   English

React Ant Design 表过滤不起作用

[英]React Ant Design table filtering not working

I am trying to implement the ant design table filtering functionality within my react component, however, I am having an issue displaying the actual values of the data I am trying to filter through.我试图在我的反应组件中实现蚂蚁设计表过滤功能,但是,我在显示我试图过滤的数据的实际值时遇到了问题。 The data is populated in the array (this.state.data) and the drop down displays the actual length of data in the array but no actual visible data/values of the names I am trying to display.数据填充在数组 (this.state.data) 中,下拉列表显示数组中数据的实际长度,但没有我试图显示的名称的实际可见数据/值。 Any help would be much appreciated.任何帮助将非常感激。

    const registeredUsersColumns = [
  {
    title: "Name",
    dataIndex: "Name",
    key: "1",
    filters: this.state.data,
    onFilter: (value, record) => record.Name.indexOf(value) === 0,
  }]

OnFilter 必须返回这个值: record[indexOftheFiltringColumn]

To obtain the desired behavior change .indexOf to .includes :要获得所需的行为更改.indexOf.includes

onFilter: (value, record) => record.name.includes(value),

// and 

onFilter: (value, record) => record.address.includes(value),

Fixed CodeSanbox link .固定 CodeSanbox 链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM