I cretated a PrimeFaces dataTable:
I've searched for a solution too and after reading this thread I've found out that there's a new Primefaces feature which allows you to save the state of the datatable.
So for Primefaces v6.0.10+ you can simply add multiViewState="true"
.
Note that this will also save filter, sorting, current page and selection beside rows per page.
Here's the link to the official demo of this feature: https://www.primefaces.org/showcase/ui/data/datatable/tableState.xhtml