rubanraj54 / vue-bootstrap4-table

Advanced table based on Vue 2 and Bootstrap 4 ⚡️
MIT License
219 stars 57 forks source link

Keeping the current index when queryparams have been changed #18

Closed sdrig closed 5 years ago

sdrig commented 5 years ago

Hi, I would like to thank for this amazing grid. I've been trying to solve one of my requirements that says when the current queryparams changed the page index has to be changed to 0 (zero).

repro : 1- call fetchdata when component mounted. 2- change page index to 2 3- enter some value into the global search.(considering that server will response only one page) 4- grid does not show any result due to page index current value is still 2

rubanraj54 commented 5 years ago

Hi @sdrig

Thanks for letting me know this issue. I will try to reproduce this issue and fix it in my next release (probably this weekend).

Cheers, Ruby.

rubanraj54 commented 5 years ago

Hi @sdrig

I couldn't be able to reproduce this issue.

In the current version, if there is a change in queryParams it triggers an event and the user can fetch new data and assign it to the table. So now the table will move the index automatically to the initial position (zero).

If you can make a fiddle/codepen, it would be easy for me to debug more in-depth.

Cheers, Ruby.

rubanraj54 commented 5 years ago

Hi @sdrig ,

I implemented a few features in today's release which includes preserving the page index. So please update the package and try it out.

To enable preserving pagination index, you should set preservePageOnDataChange: true in the config. By default, it is set to false.

In your case, I guess it will work out of the box. Whenever query changes, then the page index will become 0 (first page).

Cheers, Ruby.

sdrig commented 5 years ago

It's working like a charm! Thanks

rubanraj54 commented 5 years ago

Hi @sdrig ,

Good to see that it works.

If you would like to support this plugin, please star this repository :-)