Search code examples
angularng2-smart-table

How to update pagination action in ng2-smart-table


In angular app, I have used ng2-smart-table. And I have enable pagination in that. But it shows normal look. Instead of that default look, I have used dropdown with page option.

<select>
  <option>5</option>
  <option>10</option>   
  <option>15</option>
</select>

I have set change event also.

Issues:

1) How can I update ng2-smart-table to set page size as per value change.

2) I want to also move on specific page. E.x: Table has 1000 data and per pager there are 10 records. So I want to just on page of 14. So, how can I do that?

For that, I have refer it's documentation but I didn't get any event for that.


Solution

  • To update perpage value.

    this.DataSource.getPaging().perPage = event.target.value;
    

    And to set a specific page you have to use setPage().

    this.DataSource.setPage(3); // Pass page number
    

    It works fine for me. for details example please see this link.