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

Filtercontroll overwrites the pageNumber #7287

Open
nevermind2001 opened this issue Apr 20, 2024 · 3 comments
Open

Filtercontroll overwrites the pageNumber #7287

nevermind2001 opened this issue Apr 20, 2024 · 3 comments
Labels
Bug Issues which are marked as Bug confirmed Issues that have been confirmed with a reduced test case and identify a bug. filter-control Issues for the filter-control extension.

Comments

@nevermind2001
Copy link

nevermind2001 commented Apr 20, 2024

Bootstraptable version(s) affected

1.22.4

Description

Hi

i have a problem with cookie and pagination: if i reload the site, it always jumps back to the first page of table. after reload you can see, that the table is "opened" at the correct (last seen) page but then jumps to first page.

please see example. switch to another page of table and re-run code.

if you set data-filter-control to "false" it works.
if you set data-side-pagination to "server" it works

But with one of those options enabled it does not.

Example(s)

https://live.bootstrap-table.com/code/nevermind2001/17493

Possible Solutions

No response

Additional Context

No response

@nevermind2001 nevermind2001 added the Bug Issues which are marked as Bug label Apr 20, 2024
@wenzhixin wenzhixin added cookie Issues for the cookie extension. filter-control Issues for the filter-control extension. labels Apr 24, 2024
@nevermind2001
Copy link
Author

nevermind2001 commented Apr 29, 2024

I´m investigating a little bit more and i think the problem is not the cookie extension but the filter control. Even if i´m not using cookies but the data-page-number option, it always jumps to page one, ignoring the data-page-number value:

https://live.bootstrap-table.com/code/nevermind2001/17532

@UtechtDustin
Copy link
Collaborator

UtechtDustin commented May 26, 2024

I debugged this issue and found the cause.
The filter-control extension will trigger the onSearch method
https://github.com/wenzhixin/bootstrap-table/blob/develop/src/extensions/filter-control/bootstrap-table-filter-control.js#L517

The onSearch will reset the pageNumber to 1 (https://github.com/wenzhixin/bootstrap-table/blob/develop/src/bootstrap-table.js#L991) if we don't pass firedByInitSearchText: true as method parameter, which is not the case yet. That means we will instantly overwrite the page number to 1, after the filer-control extension was loaded and the filters was rendered.
To fix that we have to check if the filters are rendered finally and if not we have to pass firedByInitSearchText: true as parameter to the onSearch method.

@UtechtDustin UtechtDustin removed the cookie Issues for the cookie extension. label May 26, 2024
@UtechtDustin UtechtDustin changed the title Pagination, Cookie Problem - Last active page not opened after reload Filtercontroll overwrites the pageNumber May 26, 2024
@UtechtDustin UtechtDustin added the confirmed Issues that have been confirmed with a reduced test case and identify a bug. label May 26, 2024
@rohitnarayanan
Copy link

Adding another scenario .... Pagination Load More + Filter Control

  • If filterControl is in use along with paginationLoadMore, then page resets to 1 every time additional server data is pulled.
  • Works fine if filterControl is disabled for the table of none of the columns have filterControl enabled
  • In a local test, it also works if filterControl is 'input' but breaks when set to 'select'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues which are marked as Bug confirmed Issues that have been confirmed with a reduced test case and identify a bug. filter-control Issues for the filter-control extension.
Projects
None yet
Development

No branches or pull requests

4 participants