wenzhixin / bootstrap-table

An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation, Vue.js)
https://bootstrap-table.com/
MIT License
11.74k stars 4.44k forks source link

Filter Control: onPageChange events triggered a lot on reload using cookies #6270

Open francogp opened 2 years ago

francogp commented 2 years ago

Bootstraptable version(s) affected

1.20.2

Description

Every input saved on a cookie, trigger an onPageChange event when page is reloaded or when hit RUN on the example. It should only be triggered once.

Example(s)

type this filter on the example

image

Then hit RUN, and you will see the event execute 4 times. On a real web, when I reload the page, it also executes 4 time the event.

https://live.bootstrap-table.com/code/francogp/12103

Possible Solutions

No response

Additional Context

No response

UtechtDustin commented 2 years ago

This happens because the table currently will be rendered multiple times (through the historical growth of the BT). In that case the filter-control extension will call the internal function onSearch per input which will call updatePagination and this function will trigger the events. I don't think we can fix that right now, for that we have to rewrite a LOT of the BT. That should be goal for a further version, but this could take a long time from now.

Maybe @djhvscf have an idea, how we could solve this issue temporary.

djhvscf commented 2 years ago

Yes, @UtechtDustin said.. this is a known issue and also a difficult issue to solve since it is related to how the core works. At the moment there's no any workaround for this problem.