import React from "react"; import styles from "./index.less"; import { Table, Input, Button, Icon } from "antd"; import Highlighter from "react-highlight-words"; const data = [ { key: "1", name: "John Brown", age: 32, address: "New York No. 1 Lake Park" }, { key: "2", name: "Joe Black", age: 42, address: "London No. 1 Lake Park" }, { key: "3", name: "Jim Green", age: 32, address: "Sidney No. 1 Lake Park" }, { key: "4", name: "Jim Red", age: 32, address: "London No. 2 Lake Park" } ]; class App extends React.Component { state = { searchText: "" }; getColumnSearchProps = dataIndex => ({ filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => (
{ this.searchInput = node; }} placeholder={`Search ${dataIndex}`} value={selectedKeys[0]} onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : []) } onPressEnter={() => this.handleSearch(selectedKeys, confirm)} style={{ width: 188, marginBottom: 8, display: "block" }} />
), filterIcon: filtered => ( ), onFilter: (value, record) => record[dataIndex] .toString() .toLowerCase() .includes(value.toLowerCase()), onFilterDropdownVisibleChange: visible => { if (visible) { setTimeout(() => this.searchInput.select()); } }, render: text => ( ) }); handleSearch = (selectedKeys, confirm) => { confirm(); this.setState({ searchText: selectedKeys[0] }); }; handleReset = clearFilters => { clearFilters(); this.setState({ searchText: "" }); }; render() { const columns = [ { title: "Name", dataIndex: "name", key: "name", width: "30%", ...this.getColumnSearchProps("name") }, { title: "Age", dataIndex: "age", key: "age", width: "20%", ...this.getColumnSearchProps("age") }, { title: "Address", dataIndex: "address", key: "address", ...this.getColumnSearchProps("address") } ]; return ; } } export default () => (
);