Error when attempting to destroy after child row is created

Error when attempting to destroy after child row is created

isherwoodisherwood Posts: 10Questions: 0Answers: 0
edited September 2014 in DataTables 1.10

We're using DT v1.10.2 to present search results. Some of those are movie links, which invoke a movie player in child rows. Once a movie has been played, the following error results when a new search is run, preventing the search results from being repopulated in the table.

Uncaught TypeError: Cannot read property 'length' of undefined

The error occurs after the 3rd line in this function:

var bb = function (a) {
    var b = a.context;
    b.length && a.length && (a = b[0].aoData[a[0]], a._details && (a._details.remove(), a._detailsShow = l, a._details = l))
}, Tb = function (a, b) {
    var c = a.context;
    if (c.length && a.length) {
    ...
    }
};

At this point a is an object and b is undefined.

Here's the relevant portion of the init function:

    seriesTable = jQuery(table).DataTable({
        "bFilter": false,
        "bLengthChange": true,
        "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
        "bAutoWidth": false,
        "sPaginationType": "full_numbers",
        "bDestroy": true,
        "bJQueryUI": true,
        ...

And we're creating the child rows like this:

newChildRow.child(newChildRowData).show();
clickedRow.addClass('shown');

Thank you.

Replies

  • isherwoodisherwood Posts: 10Questions: 0Answers: 0
    edited September 2014

    Here's the relevant bit from the unminified file (starting at line 7803). At the if statement api is an object and ctx is undefined.

    var __details_remove = function ( api ) {
    
    var ctx = api.context;
    
    if ( ctx.length && api.length ) {
    
  • rxm023rxm023 Posts: 2Questions: 1Answers: 0

    I found workaround to this issue. I cleared all the rows before destroying data table. Here is my solution.

    seriesTable.clear().destroy();

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Hi,

    Thanks for flagging this up. I've just committed a fix and the nightly is currently rebuilding with the fix. It will be part of 1.10.3 which should be published by the end of the month.

    Thanks,
    Allan

  • isherwoodisherwood Posts: 10Questions: 0Answers: 0
    edited September 2014

    Fantastic! Thanks to both of you. I was at my wit's end with this project.

  • isherwoodisherwood Posts: 10Questions: 0Answers: 0
    edited September 2014

    I'm seeing another error that may be related... after table.clear().destroy() and re-init, I cannot invoke a new child row due to the following error:

    "Uncaught TypeError: Cannot read property '_detailsShow' of undefined"

    It occurs in this function at line 7969:

    if ( ctx.length && this.length ) {
        // _detailsShown as false or undefined will fall through to return false
        return ctx[0].aoData[ this[0] ]._detailsShow || false;
    }
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Can you link to a page demonstrating the problem so I can debug and fix it if there is a problem in the DataTables core please.

    Allan

  • isherwoodisherwood Posts: 10Questions: 0Answers: 0

    Thanks, Allan. I'll contact you privately when I have something I can share.

This discussion has been closed.