DataGrid and DataTable: rows- and first-attributes ignored after use of paginator
See original GitHub issue1) Environment
- PrimeFaces version: 7.0/7.1-SNAPSHOT
- Does it work on the newest released PrimeFaces version? Version? No, neither with 7.0, nor with 7.1-SNAPSHOT.
- Does it work on the newest sources in GitHub? (Build by source -> https://github.com/primefaces/primefaces/wiki/Building-From-Source). No.
- Application server + version: Tested with Wildfly 11 and Jetty 9.4.15 from the primefaces-test project.
- Affected browsers: probably all (tested with Firefox 60.7.0esr, Opera 58 and Chromium 75). Note: Opera and Chromium seem to have other problems with 7.1-SNAPSHOT, which is probably unrelated)
2) Expected behavior
The rows
-attribute from the <p:dataGrid>
component should always use the actual value.
3) Actual behavior
After the use of the pager, the rows
-attribute seems to be ignored and the last value before the pager was used is always used, no matter what the actual value of the rows EL is.
4) Steps to reproduce
- clone https://github.com/matinh/primefaces-test.git using the branch dataGrid with
git clone 'https://github.com/matinh/primefaces-test.git' -b dataGrid
- change directory
cd primefaces-test
- run
mvn jetty:run-exploded
- goto http://localhost:8080/primefaces-test/
- use the spinner to change number of rows in the dataGrid
- use pager to switch to another page
- try to use spinner again to change number of rows, which is no longer working.
Further comments
- There are no JavaScript Errors in the browsers console.
- The setter of the columns-attribute is called with the correct value.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
HTML5 data-* is being ignored — DataTables forums
Hey there, I'm trying to to sort one of our tables based off of a prescribed value according to the contextual value of...
Read more >jQuery datatable ignores rows with colspan - Stack Overflow
I recommend to use this solution direct from datatable. DataTables hidden row details example. works great.
Read more >Pagination: Core Feature of our Datagrid - AG Grid
One such feature is Pagination. Use Pagination when you don't want the user to have to scroll. Pagination allows viewing rows one page...
Read more >Post processing of search results patent application class
Embodiments of the present invention organize and view data using abstract records. Specifically, users compose a query according to the logical relationships ...
Read more >Page 13 – Angular, PWA, C#, ASP.NET, Node ... - Bhavin Patel
Angular apps are modular and so in general we assemble our application from many modules. A typical module is a cohesive block of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I checked some primefaces sources and it seems like the problem is in L297 https://github.com/primefaces/primefaces/blob/e2062dc5671b10e9f3913b454d4c31b86a62c226/src/main/java/org/primefaces/component/api/UIData.java#L290-L307
A possible fix might be to check for an exisitng value expression as in L305 and only set that value to the new one e.g.
Ok, I did some further research to see what actually happens. Here we go: The
DataGridRenderer
when rendering the grid, only usesUIData.getRows()
and never queries the ValueExpression directly.UIData.getRows()
is like this:and
eval()
is defined like this:So as long as
setRows()
was not called,getRows()
effectively usescomponent.getValueExpression('rows')
which is what we want.When the pager is used,
updatePagination()
is called which, in the unmodified version, sets the new rows-value to whtaever was submitted by the pager: https://github.com/primefaces/primefaces/blob/e2062dc5671b10e9f3913b454d4c31b86a62c226/src/main/java/org/primefaces/component/api/UIData.java#L283-L297From now on, calls to
UIData.getRows()
return the last value submitted by the pager and never use the ValueExpression like before.The changes from PR https://github.com/primefaces/primefaces/pull/4937 now avoid using the setter when a ValueExpression was used for the corresponding attributes but instead write to the ValueExpression. Only when no (writeable) VE was in use the submitted value is written directly into the component state.
Conclusion: IMHO the suggested fix should be ok. I’m not 100% sure if this is the suggested way, how PrimeFaces components should handle this situation, but currently I do not see any problems with this approach and I did quite some testing with DataGrid, and DataTable, included filtering, sorting, mutiViewState, paging, etc.