Is it possible to get the "active" pagination length when the stateSave is true?
Is it possible to get the "active" pagination length when the stateSave is true?
![Pepayu](https://secure.gravatar.com/avatar/e820e124c0c3ac52b7427e13b6be8a6f/?default=https%3A%2F%2Fvanillicon.com%2Fe820e124c0c3ac52b7427e13b6be8a6f_200.png&rating=g&size=120)
I have something like this
buttons: [
{
text: 'Show',
attr: { id: 'showBtnPlaceholder' },
action: function (e, dt, node, config) {
}
},
{
text: '25',
attr: { id: 'pagination25' },
action: function (e, dt, node, config) {
toy= true;
table.page.len(25).draw();
}
},
{
text: '50',
attr: { id: 'pagination50' },
action: function (e, dt, node, config) {
toy= true;
table.page.len(50).draw();
}
},
It is working as intended, basically i did a button type "show number in page" type instead of dropdown due to requirement.
However, another requirement is that they want to see what is the current pagination being used if it is 25 or 50, so this is on page load or when clicked and i will play with it in jquery/javascript
I'm thinking if there is a way to put the "active" something like in a radiobutton on the ACTIVE page.length?
Thanks!
Replies
The
page.len()
API is both a getter and setter. Use it to get the current page length.Kevin
Hi @kthorngren, how I can initially get the value of page.len() upon pageload?
Use
initComplete
orready()
to get the page length after Datatables initializes.Kevin
Hi @kthorngren i did create this:
but:
error states
Cannot read properties of undefined (reading 'page')
Please note that this is the same var table from my inside my table as my question
Hi again @kthorngren
Did try the ready()
and it worked! thank you! but why does the initComplete not working? Just curious
The problem is that the API hasn't been assigned to the
table
variable yet as the call toDataTable(...)
hasn't competed. You can get an instance of the API usingthis.api()
, for example:Kevin