Saulis / iron-data-table

iron-data-table is a Web Component for displaying data as a table or grid. Built on top of iron-list using Polymer.
Apache License 2.0
147 stars 66 forks source link

datasource not triggered when the size (total no.of records) and pageSize vary only by 6 #133

Closed rosepriya-jk closed 7 years ago

rosepriya-jk commented 8 years ago

For server-side pagination, the datasource is not triggered, when the size is more than the default pageSize which is 50, but not more than 57, since the currentPage value is not updated. The currentPage value gets rounded-off to 0 in this case.

Saulis commented 8 years ago

Hi!

Could you post an example app (jsbin preferably) where this happens? Thanks!

rosepriya-jk commented 8 years ago

Hi, Sharing a jsbin example of the issue

Saulis commented 8 years ago

Thanks! I'll try to fix this asap

sravan-s commented 8 years ago

@Saulis We kinda got a fix https://github.com/sravan-s/iron-data-table/commit/cbb125d076e315ee90e67fec1e956b4fcd1977d9

sravan-s commented 8 years ago

:question: @Saulis I have a question, would there be any benefits if we place the code calculating 'this._currentPage' inside a debounce function? That function is getting triggered a lot. This is it: https://github.com/sravan-s/iron-data-table/commit/3dd3116cde2d15cfa311392a350fd19a2a00ce4f

Saulis commented 8 years ago

The actual problem here was that the size is set after the first page has been loaded and the table doesn't react to data source size changes automatically, therefore loading the second page which contains items 50-54.

I've made a PR that tries to update the last page after size is increased. Meanwhile, you can as a workaround just set the size before any data is loaded.

@sravan-s not sure if debouncing that would help anything, _currentPage doesn't change on every scroll event which triggers all the actual data loading. Only thing that might need optimizing is that scrollTop is read multiple times, but I think browsers cache that.

If the branch refresh-on-increase works for you, I'll merge and publish it.