Can I Dynamically Add/Remove Paging?
Can I Dynamically Add/Remove Paging?
Hello,
I have a DataTable that was created like this:
var phTable = $("#priceHistoryTable").DataTable({
"dom": 'trp',
'pagingType': 'simple_numbers',
'pageLength': PAGE_LENGTH,
'paging': true,
"order": [[0, "asc"]]
});
I need to dynamically (that is, after the DataTable has been created) change both the pageLength and paging options depending on various conditions. I do not want to re-create the DataTable with different pageLength and paging options because some of the rows in the DataTable will already have child rows and I do not want to lose those.
I know there is a Settings object but according to the documentation, this object is not writable. I tried to modify it anyway, hoping it would allow me to dynamically add/remove paging but it didn't work.
Is it possible to achieve this?
Thanks.
Tom
Answers
Hi Tom,
The
pageLengthoption can be changed viapage.len(). You can't disable and enable paging dynamically, but you can usepage.len()to set the page length to -1 (i.e. show all rows) which has the visual effect of the same thing.Also, take a look at this plug-in which you might find useful.
Allan