Cast a javascript var to an existing datatable

Cast a javascript var to an existing datatable

dhicksondhickson Posts: 2Questions: 0Answers: 0
edited March 2011 in General
If I don't have a reference to an existing jQuery datatable, how can i get one? i.e. how can I cast a javascript variable to an existing datatable so I can call datatable functions upon it?

I want to do this:

var mytable=(dataTable)$("#mytableid");
mytable.fnGetNodes().serialize();

The following doesn't work:

var mydata= $("#mytableid").fnGetNodes().serialize();

presumably because jQuery doesn't realise I am operating against a datatable. To be clear, I know the id of the table, but I don't have a reference to it. Thanks.

Replies

  • enriqueimtzenriqueimtz Posts: 1Questions: 0Answers: 0
    Hi dhickson,

    I have the exact same problem, where you able to find a solution?
  • cg3cg3 Posts: 2Questions: 0Answers: 0
    I think you should be able to do $("#mytableid").dataTable().fnGetNodes().serialize();

    or

    var OTable = $("#mytableid").dataTable();
    //You now have the table
    var serializedData = OTable.fnGetNodes.serialize();
This discussion has been closed.