wikiti / jquery-paginate

A simple pagination plugin for html tables.
MIT License
14 stars 16 forks source link

Page limit records display count #2

Closed GirishaVil closed 6 years ago

GirishaVil commented 6 years ago

how to get number of records per page limit?

Dolu- commented 6 years ago

Hello, you know the limit when you setup the component :

$('#myTable').paginate({
  limit: 10 // 10 elements per page
})

But you can't get it once it's initialized. You have to modify the code. For instance, you could change the build method to return the Paginator object instead of the container (line 23) :

      ...
      build: function(obj, opts) {
        this.obj = obj;
        this.options = opts;

        if(!this.options.optional || this._totalRows() > this.options.limit) {
          this._createNavigation();
          this._setPage();
        }

        if(this.options.onCreate) this.options.onCreate(obj);

        return this; // instead of return this.obj;
      },
      ...

This way you can access the options used to setup your pagination :

var myPaginator = $('#myTable').paginate({
  limit: 10 // 10 elements per page
})
...
alert(myPaginator.options.limit);
wikiti commented 6 years ago

Hello @GirishaVil!

As noted by @Dolu-, you may either:

  1. Access the options property after initializing the paginator.
  2. Store the limit yourself in a constant or a variable.

If you think there should be a data or property accessor for this kind of options, feel free to comment and reopen this issue.

Best regards, Daniel