question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DataTablePagerComponent custom number of displayed pages.

See original GitHub issue

I’m submitting a … (check one with “x”)

[ ] bug report => search github for a similar issue or PR before submitting
[x ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior DataTablePagerComponent can’t be configured to display custom number of pages. Currently it’s hardcoded to display 5 pages always.

const maxSize = 5;

Expected behavior User should be able to set a custom number of elements to be displayed which fits his project requirements.

I already implemented it in my current project by adding a variable which can be passed from the template. If anyone interested I can create a pull request.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:12
  • Comments:30 (12 by maintainers)

github_iconTop GitHub Comments

9reactions
tplkcommented, Jun 8, 2017

@mvhecke here’s an example:

image

Pager displays 5 pages and it’s okay when you only have pagination in the footer. But what if we need extra information there?

image

Well, it seems logical to reduce pager’s width so it doesn’t take 1/3 of footer’s width.

image

Another use case is a mobile layout where viewport width causes default pager to wrap.

image

3reactions
tplkcommented, Jun 13, 2017

@rahul-winner sure, here’s working example: https://plnkr.co/edit/ym689j You can create custom footer template and move select element there:

<ngx-datatable-footer>
  <ng-template
    ngx-datatable-footer-template
    let-rowCount="rowCount"
    let-pageSize="pageSize"
    let-selectedCount="selectedCount"
    let-curPage="curPage"
    let-offset="offset"
  >
    <div class="datatable-footer_pagination">
      <datatable-pager
        [page]="curPage"
        [size]="pageSize"
        [count]="rowCount"
        [hidden]="false"
        (change)="table.onFooterPage($event)">
      </datatable-pager>
      <div class="page-limit-container">
        <select (change)="onLimitChange($event.target.value)" class="page-limit">
          <option
            *ngFor="let option of pageLimitOptions"
            [value]="option.value"
            [selected]="option.value == currentPageLimit"
          >
            {{option.value}} per page
          </option>
        </select>
      </div>
    </div>
  </ng-template>
</ngx-datatable-footer>
Read more comments on GitHub >

github_iconTop Results From Across the Web

DataTables example - Alternative pagination
There are six built-in options for which pagination controls DataTables should show: numbers - Page number buttons only; simple - 'Previous' and 'Next' ......
Read more >
Customize ngx-datatable pager component to show Text ...
I am Customizing the datatable-pager in ngx ...
Read more >
Angular Ngx Datatable Custom Paginator (forked)
Example of ngx-datatable custom paginator with variable count of visible pages.
Read more >
Examples › Pagination | Mantine DataTable - GitHub Pages
page → the current page number · onPageChange → a callback that is executed when the user changes the current page · totalRecords...
Read more >
Bootstrap 4 table pagination - examples & tutorial.
By default, pagination is initialized with Previous, page numbers and Next buttons. To manipulate the table pagination we can use one of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found