darrachequesne / spring-data-jpa-datatables

Spring Data JPA extension to work with the great jQuery plugin DataTables (https://datatables.net/)
Apache License 2.0
447 stars 173 forks source link

How to change the result count using specification? #89

Closed Mike-the-one closed 5 years ago

Mike-the-one commented 5 years ago

So my DB has items from multiple users. The datatable is for individual users. I need to use Specification to specify that the query is for a logged in user, which works fine. Now the problem is the total entries.

For example, i have two users, user A has 57 items, user B has 600 items, and the datatable shows this:

Showing 1 to 10 of 57 entries (filtered from 657 total entries)

the total is for both user a and b. But I only want to show this for user a, so I want this:

Showing 1 to 10 of 57 entries (filtered from 57 total entries).

How to do that?

thanks

darrachequesne commented 5 years ago

Hi! The preFilteringSpecification allows you to apply a specification on the total number of entities. Please see https://github.com/darrachequesne/spring-data-jpa-datatables#api

Mike-the-one commented 5 years ago

Thanks that worked!!!