REACT-antd的table的筛选问题

REACT-antd的table的筛选问题


作为一个刚刚接触react的小白,最近在学习的过程中碰到了不少问题,其中有些不可避免且努力了好久都没什么效果的问题,姑且先埋个坑吧,说不定以后就会了呢,要是有大牛看见愿意扶我一把那就更好了。
好,接下来进入正题。问题1是这样的:在我使用antd的table的时候,发现其中的筛选功能好像是写死了的,比如antd中原来的筛选功能是写在name上的,然后我把它改成age之后,就报错了:TypeError: record.age.includes is not a function.感觉应该是record里面的数据的问题,但是我又看不到也没啥办法。
然后是问题2:在实现搜索功能的时候,还原搜索使用antd给的办法没问题,在67、68行那里,
<Button onClick={() => this.handleReset(clearFilters)} size=“small” style={ { width: 90 }}>
Reset

但是我在外面又用了一个按钮来实现这个功能,就只能实现一半,高亮倒是没了,不过icon样式没变回去,然后数据也没有显示成搜索之前的样子。在164行<Button onClick={() => this.handleReset(this.clearFilters)}>Clear Search
这里我是真的不会,求帮助!
下面献上我拙劣的代码,希望有大佬可以帮我看看。

import React from 'react';
import {
    Table, Button , Input , Icon  } from 'antd';
import Highlighter from 'react-highlight-words';
import axios from 'axios';
import './style.css';

class MyTable extends React.Component {
   
  state = {
   
        filteredInfo: null,
        sortedInfo: null,
        searchText: '',
        data: []
  };

  handleChange = (pagination, filters, sorter) => {
   
    this.setState({
   
      filteredInfo: filters,
      sortedInfo: sorter,
    });
  };
//还原筛选
  clearFilters = () => {
   
    this.setState({
    filteredInfo: null });
  };
//还原排序
  clearSorted = () => {
   
    this.setState({
    sortedInfo: null });
  };
//还原搜索
  clearSearch = clearFilters => {
   
    clearFilters();
    this.setState({
    searchText: null });
  }; 
//一键还原
  clearAll = () => {
   
    this.setState({
   
      filteredInfo: null,
      sortedInfo: null,
      searchText: null
    });
  };

  getColumnSearchProps = (dataIndex) => ({
   
    filterDropdown: ({
    setSelectedKeys, selectedKeys, confirm, clearFilters }) => (
      <div style={
   {
    padding: 8 }}>
        <Input
          ref={
   node => {
   
            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' }}
        />
        <Button
          type="primary"
          onClick={
   () => this.handleSearch(selectedKeys, confirm)}
          icon="search"
          size="small"
          style={
   {
    width: 90, marginRight: 8 }
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
react-antd-treetable是一个基于React和Ant Design框架开发的树形表格组件。该组件提供了一个功能强大且易用的界面,用于展示具有树形结构的数据react-antd-treetable组件主要特点如下: 1. 树形结构:组件支持展示具有树形结构的数据,每个节点可以包含子节点,形成层叠的树状布局。 2. 数据排序:可通过点击表头进行排序操作,对树形表格中的数据进行升序或降序排序。 3. 行选择:可以通过点击表格的行来选择或取消选择特定的行数据。同时,也支持通过选择父节点实现对整个子节点的选中或取消选中。 4. 编辑功能:支持在表格中对特定单元格的数据进行编辑,提供了输入框等组件供用户进行修。 5. 展开/收起:可以通过点击加号和减号来展开或收起树形表格中的子节点,以便更清晰地查看和管理数据。 6. 异步加载:支持异步加载数据,可以根据需要动态加载子节点数据,提高了性能和效率。 7. 数据过滤:组件提供了一个搜索框,可以根据用户输入的关键字来过滤和筛选需要展示的数据,方便用户快速找到所需数据。 总的来说,react-antd-treetable是一个功能丰富且易于使用的树形表格组件,适用于需要展示树形数据结构的项目。无论是对于数据展示、编辑、排序、选择还是过滤等功能,该组件都提供了完善的解决方案,方便开发者快速构建符合需求的树形表格界面。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值