Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to get filtered and/or sorted data in DataTable #643

Closed
mengjade opened this issue Nov 14, 2018 · 5 comments
Closed

Ability to get filtered and/or sorted data in DataTable #643

mengjade opened this issue Nov 14, 2018 · 5 comments
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@mengjade
Copy link

Hi, after I call the function filter on the table below, how can I get the array of filtered data?

     this.dt.filter("BMW", "brand", "in");

    <DataTable
        ref={el => (this.dt = el)}
        value={this.state.cars}
        rows={10}
      >
@weissgold
Copy link

Hello,
I would like to get the filtered data as well.

Is there a best practice to get the current array for further usage?
Kind regards

@cagataycivici cagataycivici self-assigned this Dec 4, 2018
@cagataycivici cagataycivici added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Dec 4, 2018
@cagataycivici cagataycivici added this to the 2.0.0 milestone Dec 4, 2018
@cagataycivici cagataycivici changed the title DataTable: get filtered data Ability to get filtered and/or sorted data in DataTable Dec 4, 2018
@cagataycivici
Copy link
Member

With 2.0.0-final, it is possible via the new onValueChange callback;

<DataTable value={this.state.cars} onValueChange={filteredData => console.log(filteredData)}>
    <Column field="vin" header="Vin" filter={true} />
    <Column field="year" header="Year" filter={true} />
    <Column field="brand" header="Brand" filter={true} />
    <Column field="color" header="Color" filter={true}  />
</DataTable>

@sajjanhubale
Copy link

is this final version released?

@thoughtworks-tcaceres
Copy link
Contributor

thoughtworks-tcaceres commented Jan 14, 2020

The filtered data becomes undefined if the page number changes or number of row changes.
Also, the onValueChange doesn't get triggered if the global filter is changed.
Is this working as intended?

@johntheZ
Copy link

Is there a way to access the "filteredData" when the value for the datatable changes, i.e. the value is fetched through API call, and the value change through react state, but it would not reflect in filteredData as the callback would not be invoked? Is there to invoke it again and only get the filteredData again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

6 participants