Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81688

Dynamically add/remove columns -> DataTables warning. Requested unknown parameter...

$
0
0
Hello Allen.

I am using a js array and passing it into dataTables using the aaData option. When my page loads, aaData contains 5 columns of data. When I initialize my datatable, I pass in aaData and aoColumnDefs which also contains 5 elements.

When the user clicks on an element in the list on the left, I retrieve data from the server using $.ajax(). The data is returned as an array of values. The values are pushed into each corresponding row of aaData and a new column definition is pushed into aoColumnDefs.

I then use the modified aaData and aoColumnDefs (containing the new elements) to initialize my datatable after I completely destroy it using fnDestroy().

Adding columns dynamically works very well in this scenario.

I am using fnDrawCallback to bind a handler to the click event of a span element that is contained within the sTitle property of column. When the span is clicked, I remove the column from both aaData and aoColumnDefs and I reinitialize my datatable using the new options for aaData and aoColumnDefs after the previous datatable is destroyed via fnDestroy and the table markup is replaced.

I am having trouble understanding why I am getting the infamous DataTables warning. Requested unknown parameter... warning since I am destroying my datatable, replacing any existing table markup in my table container, and calling .dataTable() to initialize a completely new data table using the modified aaData and aoColumnDefs arrays.

Debug link:

http://debug.datatables.net/adicin

This is really important to me. I hope you can help.

Many, many thanks.

Robert

Viewing all articles
Browse latest Browse all 81688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>