Can I Dynamically Add/Remove Paging?

Can I Dynamically Add/Remove Paging?

tlbaxter99tlbaxter99 Posts: 5Questions: 4Answers: 0
edited March 2016 in Free community support

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

  • allanallan Posts: 63,783Questions: 1Answers: 10,511 Site admin

    Hi Tom,

    The pageLength option can be changed via page.len(). You can't disable and enable paging dynamically, but you can use page.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

This discussion has been closed.