Ember-cli-pagination pagedArray only load first page's data


#1

I am using this way to do the pagination:

pagedEvents: pagedArray(‘events’, { pageBinding: ‘page’, perPageBinding: ‘perPage’, totalPagesBinding: ‘totalPages’ }),

the ‘events’ is returned from model() and I made the backend to return “perPage”'s records every time I click the page number, the thing is: in the page, I can receive the data in Response but it only display first page’s data. And I did check the ‘events’ get updated every time, but It just didn’t shown on the page.


#2

I think it should be something like this:

  pagedEvents: pagedArray('events', {
    page: alias('parent.page'),
    perPage: alias('parent.perPage')
  }),

and on the controller

import Controller from '@ember/controller';

export default Controller.extend({
  page: 1,
  perPage: 5,
  query: '',

  queryParams: ["page", "perPage", "query"]
});

#3

Thanks for reply. I know this binding way is deprecated now and I tried the way you mentioned using alias, but I don’t think is “binding” causing any problems since I am using {{#each pagedEvents as |event|}} to show the data on the page, if I replace “pagedEvents” with “events”, it works well but lost some functionality like sort and filter. And also I notice this way is making page a computedProperty, but I noticed in ember toturial which said computedProperty can’t be used as queryParamas. I don’t know if I understand this correctly though.

{{#each events as |event|}} {{page-numbers content=pagedEvents showFL=true}} This will work but I wanna give some functionality like sort and filter to this “events2” I used here: pagedEvents: pagedArray(‘events2’,


#4

It should work. See

and the https://bloggr.exmer.com demo.


#5

Thanks so much. I will try this.