superRaytin / paginationjs

A jQuery plugin to provide simple yet fully customisable pagination.
http://pagination.js.org
MIT License
912 stars 659 forks source link

how set pages number gotten from responce as a number, not as array #95

Closed nikonov91-dev closed 5 years ago

nikonov91-dev commented 5 years ago

from the server i receive nex data:

content: (2) [{…}, {…}]
number: 2
numberOfElements: 2
size: 2
sort: {unsorted: false, sorted: true, empty: false}
totalElements: 38
totalPages: 19

my pagination configs:

$('#abc').pagination({
  pageSize: 10,
  dataSource: this.props.appContext+'/admin/api/modelType/page?pageNumber=2&pageSize=2',

//how can i set totalNumber from a responce data, not a hardcoded value?
  totalNumber: 19
}

i cannot know the number before initialization. Is there any other way to make it work without providing hardcode value or array?

Of cause if i try to locate the pages quanity number with locator: 'totalPages' it says totalPages is not an array.

here is more explanation https://stackoverflow.com/questions/58200331/how-set-pages-number-gotten-from-responce-as-a-number-not-as-array-in-paginatio

Thanks

superRaytin commented 5 years ago

Guess this demo may help you: http://pagination.js.org/#totalNumber_locator