0

I'm using the dataTable plugin (datatable) to manage my HTML table.

But, when I call the init of this plug in, the data of my table... disappear! Why?

I don't know, I've already use this method and I've neved had this problem! Someone can help me?

The call for the init is:

jQuery('#measure').dataTable( {
    "bDestroy": true,  //using this because I call this init many times
    "aoColumnDefs": [
        { "bSortable": false, "aTargets": [ 0 ] },
        { "bSortable": false, "bSearchable": false, "bVisible": false, "aTargets": [ 3,4,8,9,10,11,12,13,14,15,16,17 ] },
    ],
    "aaSorting": [[5, 'asc']]
});

If I use a blocking alert in JS just before this code to see what is happening, I can see the table with the correct data. After this, I can't see the data not even from the HTML console, like firebug.

EDIT:

Maybe the problem is bDestroy? I want to insert one row per time in the table and every time I recall this init method

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Piero Alberto
  • 3,823
  • 6
  • 56
  • 108

1 Answers1

0

I got it! :)

I add the data dynamically... My problem was that I used to call the init of datatable every time I added a row...

If you want to add data dynamically, you have to call the init method only once and then use the datatable API to add/update/delete data in the table! ;)

Piero Alberto
  • 3,823
  • 6
  • 56
  • 108