primefaces icon indicating copy to clipboard operation
primefaces copied to clipboard

DataTable: Pagination combined with first not correct

Open fanste opened this issue 4 years ago • 6 comments

1) Environment

  • PrimeFaces version: 8.0

2) Expected behavior

<p:dataTable pagination="true" rows="20" first="105" ...> should be the 6th item on the 6th page.

3) Actual behavior

The 6th page is opened but the item is at the very top of that page. But if you go to another page and than back to page 6 again, the item is at the 6th position and not at 0 anymore.

grafik

What do you think. Should this be changed?

fanste avatar Mar 06 '20 09:03 fanste

you know, issues without samples are invalid :P Can you replicate it in the showcase?

tandraschko avatar Mar 06 '20 09:03 tandraschko

Well, the sample (kind of..) is provided in the expected behavior section :D

But here you go: https://github.com/fanste/primefaces-test/tree/test-5649

fanste avatar Mar 06 '20 09:03 fanste

I would not call this a defect per say. Keeping this 'working' would require passing a 'remainer' to and from the client (so it keeps working using short requestscoped backing beans) and take it into account in calculating a 'new' first. Currently page and pagesize are used for this. 'Improvement' is a better tag, but when a 'lazyDataModel' is used. this can be 'fixed' in there. Not something the datatable should support by definition. Lots of more important things to improve imo.

kukel avatar Apr 01 '20 12:04 kukel

sample not available anymore please create a issue with reproducer if its still a problem in current github master

tandraschko avatar Apr 21 '22 15:04 tandraschko

I have no idea, why the reproducer was not available anymore...

I pushed it again to the same address and upgraded it to -SNAPSHOT available on Jitpack. The behavior of the datatable is still wrong.

Open the reproducer, page 6 will be shown with item 105 at the 1st row - but the item should be the 6th row. Switch to page 1 and back to page 6 and everything will be as expected.

fanste avatar Apr 22 '22 07:04 fanste

Could you create new integrationt test for it and work on a PR?

tandraschko avatar Apr 22 '22 07:04 tandraschko

Updated reproducer still an issue in 13.0.3:

pf-5649.zip

melloware avatar Nov 22 '23 20:11 melloware

The issue here is that you set 105 (which is not divisible by 20) as first when it should be 100 at best (or something divisible by 20). DataTable is lenient here, while it could actually throw an exception as it's not quite correct, but since it's a old issue and no one else complain about it, I'm right now more in favor to do nothing about it, or log at best

Rapster avatar Dec 27 '23 11:12 Rapster

I vote for lets log it in Development mode so its a warning that its an invalid first value?

melloware avatar Dec 27 '23 13:12 melloware