How can i change table settings on the fly?

How can i change table settings on the fly?

daniel_rdaniel_r Posts: 460Questions: 4Answers: 67
edited February 2011 in General
Hi , i got the table located inside an iframe which is located inside my main page,

When I Click a button inside my main page i want to change the bLengthChange from false to true (for example)

But how do i get the table object and how can I modify it settings?

To find the table I can do this :

[code]
var oTable = $("#iframeMyTable").contents().find("#tasksTable")
[/code]

But can I cast it to dataTables? and how can i get the current value of bLengthChange and change it to a new value?


regards

Daniel.

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    [code]
    var oTable = $("#iframeMyTable").contents().find("#tasksTable").dataTable();
    [/code]
    should get you the original DataTables instance - assuming that the table has the tasksTable ID.

    You can't change bLengthChange dynamically during run time of the table - only at initialisation. So two options: 1. reinitialise the table (use bDestroy:true as an option) or 2. simply hide the length change element.

    Allan
  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67
    Thx for the answer,
    but how can I hide/show the length element?
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    $('div.dataTables_length').css('display', 'none'); would do it.

    Allan
This discussion has been closed.