Get filtered data in component table after executing the filter function on dataSource in ant design
Get filtered data in component table after executing the filter function on dataSource in ant design
When useing the Table component in Ant-desigin, i want to get the filterd data in table after executing the filter function on the dataSource, but i cannot find the way to get it. There is a function called onChange which can only get the filter conditions which can not get the filtered data.
I'm not sure why posting code would actually help here. I'm looking for a way to do the same. You can define filters and how they work in the component to make filtering easy, but what Jochen is asking (and I'm wondering too) is, how to get the filtered data out of the
<Table>
. For example: Let's say I have an <Table>
with a dataSource
array of 50 objects, after setting my filters, the <Table>
only shows 20 objects. Now I'd like an array of these 20 objects to use somewhere else.– air
Apr 29 at 14:14
<Table>
<Table>
dataSource
<Table>
1 Answer
1
I kinda found a way. The props title
and footer
on the <Table />
component take a function which does provide the filtered data.
title
footer
<Table />
<Table
footer={currentPageData => {
console.log(currentPageData); // <-- This is an array of the filtered dataSource.
return null;
}}
/>
It seems that by this way, the
currentPageData
is the data in current page, and when the filterd data covers several pages, this method may not works. So if i want to get all the filterd data no matter how many pages it covers, which way can i do?Thx– Jochen Shi
Jun 11 at 7:57
currentPageData
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Please post your code.
– Colin
Apr 28 at 9:11