Search code examples
reactjsantd

How to access antd table current data state?


I have a table based on antd table component with custom filters like components-table-demo-filter-search

By default, I can only access to dataSource property which I provide but I can't find a way to get access to dataSource after filtering. How can I get access to filtered data?


Solution

  • You can get the filtered data source via the extra parameter of the onChange callback of the Table component.

    The signature of onChange:

    function(pagination, filters, sorter, extra: { currentDataSource: [], action: paginate | sort | filter })
    

    When the custom filterSearch function executes, the onChange callback will be executed, and you will get the filtered data source by accessing extra.currentDataSource.