Skip to content

Pagination dropdown getting close when setState({ data }) #1153

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

Closed
dekelb opened this issue Mar 16, 2017 · 9 comments
Closed

Pagination dropdown getting close when setState({ data }) #1153

dekelb opened this issue Mar 16, 2017 · 9 comments

Comments

@dekelb
Copy link
Contributor

dekelb commented Mar 16, 2017

I'm using react-bootstrap-table with remote data and fetching the data every few seconds to update the table.

<BootstrapTable
    remote={ true }
    data={ this.state.data }
    ....

And when fetching the data I use setState({ data }).

If I open the pagination menu - once the component is refreshed with the data from the server - the dropdown is getting closed automatically.

I'm using version 3.0.0

Is there something I can do to keep the pagination dropdown open?

@AllenFang
Copy link
Owner

sorry for lately reply cause of my busy job...

If I open the pagination menu - once the component is refreshed with the data from the server - the dropdown is getting closed automatically.

yap, it's not a bug, because a re-render happen via setState

Is there something I can do to keep the pagination dropdown open?

there's no any good way to achieve easily, but you can custom the dropdown and keep it always open, check this and add a props hidden={ false } on SizePerPageDropDown

Ley me know if you have any questions, thanks

@dekelb
Copy link
Contributor Author

dekelb commented Mar 25, 2017

Thanks for the fast reply @AllenFang!
Actually - if there was a callback on the open/close dropdown of the PaginationList it would be much easier.

What do you think? I can add a PR for this one, will you merge it?
Thanks!

@AllenFang
Copy link
Owner

Actually - if there was a callback on the open/close dropdown of the PaginationList it would be much easier.

I can try to add this, so is that helpful for you? I think a return bool value can perform the dropdown open/close maybe is what you want.

@dekelb
Copy link
Contributor Author

dekelb commented Mar 26, 2017

My thinking was that I can stop the refreshing from the server while the dropdown is open, and when the dropdown is closed I will renew the requests.

This way - the component will not re-render while the dropdown is open (because there will be no new requests).

@AllenFang
Copy link
Owner

sorry, I got misunderstand, for your mentioned before, I will try to support a callback on dropdown for open/close, thanks

@dekelb
Copy link
Contributor Author

dekelb commented Mar 26, 2017

Do you prefer that I provide a PR for that?

@AllenFang
Copy link
Owner

@dekelb, I think I can handle it, take your time :)

@AllenFang
Copy link
Owner

AllenFang commented Apr 12, 2017

@dekelb, I've try to implement but I found some situation here.

Firstly, bootstrap dropdown can be close via clicking the outside of dropdown itself, so if you want to know the dropdown close by this way, you need to use bootstrap.js, but react-bootstrap-table doesn't depend on it, you can check DropDown Event document,

so my recommendation is you can know it open/close via native bootstrap event, like the above reference but you need to know the DOM id or class, so I'll add a general class name on dropdown for you can get the DOM via jQuery or javascript. And I wont support the callback for you, because i can't listen the open/close event when clicking outside of dropdown, thanks

@AllenFang
Copy link
Owner

Try v3.1.8, you can get the dropdown DOM via .react-bs-table-sizePerPage-dropdown and register it with DropDown Events

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants