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

onChangeRowsPerPage is not triggered if remote data #415

Closed
justinstenning opened this issue Apr 3, 2019 · 3 comments
Closed

onChangeRowsPerPage is not triggered if remote data #415

justinstenning opened this issue Apr 3, 2019 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@justinstenning
Copy link
Contributor

Describe the bug
The onChangeRowsPerPage event is not triggered if using remote data.

To Reproduce
Steps to reproduce the behavior:

  1. Add onChangeRowsPerPage={(pageSize) => {console.log('Page size changed!'};} to remote data example (like in https://mbrn.github.io/material-table/#/docz-examples-14-example-remote-data)
  2. Change page size
  3. Do not see "Page size changed!" in console

Expected behavior
onChangeRowsPerPage handler called when a remote data source is used and user changes page size.

Workaround
Within your remote data function the new page size will be provided.

Additional context
The following is the code that produces the issue. Line 282 would need to be duplicated into the first condition.

https://github.com/mbrn/material-table/blob/master/src/material-table.js#L273

              if (this.isRemoteData()) {
                const query = { ...this.state.query };
                query.pageSize = event.target.value;
                query.page = 0;
                this.onQueryChange(query);
              }
              else {
                this.dataManager.changeCurrentPage(0);
                this.setState(this.dataManager.getRenderState(), () => {
                  this.onChangeRowsPerPage(event.target.value);
                });
              }
@justinstenning
Copy link
Contributor Author

justinstenning commented Apr 3, 2019

@mbrn I can make this change, but not sure if you want to make this or just update documentation? I'm also not sure of the ramifications of making this change.

I'm happy with the workaround for my own purposes.

@mbrn
Copy link
Owner

mbrn commented Apr 4, 2019

Hi @spazzarama ,

We can do this. But firstly we should add a callback to onQueryChange function. This callback will be fired after setState completed.

If you want you can send a PR?

Thanks for your contributions.

@mbrn mbrn self-assigned this Apr 4, 2019
@mbrn mbrn added the bug Something isn't working label Apr 4, 2019
@mbrn mbrn closed this as completed in 36de8b5 Apr 11, 2019
@mbrn
Copy link
Owner

mbrn commented Apr 11, 2019

This is done with version 1.31.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants