Dynamically change bPaginate value

Dynamically change bPaginate value

GiladDGiladD Posts: 9Questions: 0Answers: 0
edited January 2013 in General
Hi all,
Kind of a Datatables-newbie here, so bear with me... I was able to set up multiple tables on my page and it is working quite nicely, but there's one thing I just can't seem to get working.
I populate my tables with an external data source and I want to turn the pagination feature on or off based on the number of records that is currently showing, but it doesn't work. Here's my code (table4_3 is a table object, options4_3 contains the data that was used to populate the table, among other things):

[code]
var oSettings = table4_3.fnSettings();
oSettings.bPaginate = (options4_3.series[0].data.length>10);
table4_3.fnDraw();
table4_3.fnAdjustColumnSizing();
[/code]

I searched for similar questions on these forums (and elsewhere), but couldn't find a solution. I also tried with an underscore before bPaginate, but that didn't work either...

Any help is appreciated.

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    No this is not currently possible. The settings in fnSettings are private and should be treated as read only (they shouldn't even be read most of the time). Changing a value in fnSettings is a bad move as DataTables has no way of knowing that the value has changed and no way to act on it.

    If you want to hide the pagination control when there are less than 10 rows, I'd suggest you use fnDrawCallback and manipulate the `display` property of the pagination element.

    Allan
  • GiladDGiladD Posts: 9Questions: 0Answers: 0
    That's a shame to hear, but at least I now have an answer.
    Is it maybe possible to do it by re-generating the entire datatable, ie call dataTable() again ?

    Thanks, Allan!
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Yes you could use bDestroy for that, but if all you want to do is hide the pagination control, I'd very strongly suggest against that. A small plug-in or using fnDrawCallback as I say is how I would do it myself.

    Allan
  • GiladDGiladD Posts: 9Questions: 0Answers: 0
    I'll look into it. Thanks!
This discussion has been closed.