Possible bug when fnClearTable is called after a details row has been opened.

Possible bug when fnClearTable is called after a details row has been opened.

imajedi4everimajedi4ever Posts: 1Questions: 0Answers: 0

I have a dataTable which is updated on a click event of a button (submits query filter data). My table also utilizes the fnOpen() function to display a sibling 'details' row on click of an anchor tag which is within one of the columns in the main row.

Each time the submit button is clicked to update the table, I call a function called updateDatatable() which clears the table and updates it with the new data returned by the updated query.

updateDatatable : function(dataTable, newData) {
    dataTable.fnClearTable();
    dataTable.fnDraw();
    dataTable.fnAddData(newData);
}

However, I have discovered that after (and only after) I have clicked the anchor tag which displays my 'details' row, the table returns no results and in console I am getting the following error:

Uncaught TypeError: Cannot read property '_detailsShow' of undefined jquery-datatables.js:116
(anonymous function) jquery-datatables.js:116
jQuery.extend.each jquery-1.10.1.js:657
jQuery.fn.jQuery.each jquery-1.10.1.js:266
(anonymous function) jquery-datatables.js:112
jQuery.event.dispatch jquery-1.10.1.js:5116
elemData.handle jquery-1.10.1.js:4787
jQuery.event.trigger jquery-1.10.1.js:5028
(anonymous function) jquery-1.10.1.js:5712
jQuery.extend.each jquery-1.10.1.js:657
jQuery.fn.jQuery.each jquery-1.10.1.js:266
jQuery.fn.extend.trigger jquery-1.10.1.js:5711
u jquery-datatables.js:70
L jquery-datatables.js:26
M jquery-datatables.js:27
(anonymous function) jquery-datatables.js:101
s.iterator jquery-datatables.js:95
(anonymous function) jquery-datatables.js:101
(anonymous function) jquery-datatables.js:98
fnClearTable jquery-datatables.js:75

I have created a workaround for the draw.dt.DT_details() function on line 110 which seems to work:

function() {
    e.find("tbody tr").each(
        function(){
            var a=ab(d,this),a=d.aoData[a];
            if (a) { // Custom fix for possible bug that has been reported to dataTables development team.  
                a._detailsShow&&a._details.insertAfter(this)                    
            }
    })
}),

Is there a better solution here?

Thanks!
Imajedi4ever

This discussion has been closed.