Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paper-data-table-pagination doesn't work #38

Open
jfbaquerocelis opened this issue Feb 17, 2018 · 2 comments
Open

paper-data-table-pagination doesn't work #38

jfbaquerocelis opened this issue Feb 17, 2018 · 2 comments

Comments

@jfbaquerocelis
Copy link

Hi, I am using this addon and work fine but when I see closest the pagination doesn't work.

image

I know that the variables limit and page should set on my controller, but the actions incrementPage and decrementPage I don't know how to set.

Whatever help is welcome. Regards.

@electronicbites
Copy link

I also have problems, but my selects are not working. Increment and decrement page are just actions you have to catch. here is my controller:
https://gist.github.com/electronicbites/6ab19768cc0628d02bc7500d24860296

@d-arkhipenko
Copy link

d-arkhipenko commented Feb 25, 2019

works as described in README.md and with TS too.

template part

 {{paper-data-table-pagination          
          limit=this.model.transactions.pageSize
          limitOptions=this.limitOptions
          total=this.model.transactions.rowCount
          page=this.model.transactions.currentPage
          pages=this.pages
          onChangePage=(action onChangePage)
          onChangeLimit=(action onChangeLimit)
          onIncrementPage=(action onIncrementPage this.model.transactions.currentPage this.model.transactions.pageCount)
          onDecrementPage=(action onDecrementPage this.model.transactions.currentPage)}}

controller part

export default class MyProfile extends Controller {
    limitOptions: number[] = [25, 50, 100]

    get pages(): number[] {
        let model = this.model as profile;

        return Array.from({length: model.transactions.pageCount}, (_, k) => k + 1);
    }

    onIncrementPage(currentPage: number, pageCount: number) {
        currentPage +=1;

        if (currentPage > pageCount)
            return

        this.transitionToRoute('my-profile', { queryParams: { current_page: currentPage }})
    }

    onDecrementPage(currentPage: number) {
        currentPage -=1;

        if (currentPage < 1)
            return

        this.transitionToRoute('my-profile', { queryParams: { current_page: currentPage }})
    }

    onChangeLimit(chosenLimit: number) {
        this.transitionToRoute('my-profile', { queryParams: { current_page: 1, page_zise: chosenLimit }})
    }

    onChangePage(chosenPage: number) {
        this.transitionToRoute('my-profile', { queryParams: { current_page: chosenPage }})
    }
}

on route part, you will need to add this:

 queryParams = {
        current_page: { refreshModel : true},
        page_zise: { refreshModel : true}
    }

this code need to rerender model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants