I'm submitting a ... (check one with "x")
[X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Plunkr Case (Bug Reports)
Here is plucker showcasing the problem since the primeng 4.2.0-rc.1
http://plnkr.co/edit/8B98zrkaFb9KDVPQ7OmB?p=preview
Current behavior
When the rowsPerPageOptions is being changed the table should react to that and update the number of records showing in the page. This was working in previous versions. It seems the change is not being detected unless the page button is clicked, it just at that time that the table gets refreshed.
Expected behavior
By changing the rowsperpageoptions dropdown the table gets updated without any need to play with buttons to trigger change detection. This was working in primeng 4.2.1.
Minimal reproduction of the problem with instructions
Please head out to plucker link and try to change the number of records to be shown on a page, it can be seen that the table is not reacting to changes in options unless the buttons are clicked.
What is the motivation / use case for changing the behavior?
Angular version: 4.3.6
PrimeNG version: 4.2.0-rc.1
Browser: [all]
I've changed the changePageToFirst(event) to one that doesn't check if you are on first page and the component works fine again.
changePageToFirst(event) {
if (!this.isFirstPage()){
this.changePage(0, event);
}
}
changed to:
changePageToFirst(event) {
this.changePage(0, event);
}
Thanks for the comment.
I opened up the paginator.js in primeng and I found that compared to ts file it does not have the first page check. Here is the code for changePageToFirst in pagnator.js
Paginator.prototype.changePageToFirst = function (event) {
this.changePage(0, event);
};
I don't understand how the ts file is different from js file. Because I checked my npm.lock file and made sure I am using primeng 4.2.0-rc.1.
This is what I have in my js file in the node_modules/primeng/components/paginator.js (from line 101):
Paginator.prototype.changePageToFirst = function (event) {
if (!this.isFirstPage()) {
this.changePage(0, event);
}
};
and this in the line in package.json where i have the dependency:
"primeng": "4.2.0-rc.1",
If I take out the "isFirstPage() check all works well and the page reloads after I change the numeber of pages in paginator.
Thanks again. You are right my package.lock and package.json was showing 4.2.0-rc.1 but the files didn't correspond with that. I deleted node_modules and reinstalled it all and now I see the correct version. That was weird of npm. After applying your change the paginator is working again.
Hope Primeng team fixes that in the upcoming version.
Thanks again for the workaround.
Yes, hope that they arrange it in the final version soon. A pleasure!
it only works if you are not in the first page this if is screwing it:
if (!this.isFirstPage()) {
I'm going back to the version: "primeng": "4.1.3" and wait for an stable version
See #3944
Most helpful comment
See #3944