Destroy Buttons bug

Destroy Buttons bug

TylerCTylerC Posts: 3Questions: 0Answers: 0

Hello, I've found a bug in dataTables.buttons.js on line 199 in the destroy function when using 'destroy': true in DataTables initialization.

Essentially what is happening is that as we remove button nodes from the buttons array, we increment our index as we iterate through the array, but the array is getting smaller (since we're removing buttons from it). Eventually, we hit a case where the array is smaller than the index (since the index is based on the original length of the array), which throws an error.

I've fixed this in my local implementation by changing the for loop to be like so:

for ( ien = buttons.length-1 ; ien >= 0; ien--) {
this.remove( buttons[ien].node );
}

Replies

  • TylerCTylerC Posts: 3Questions: 0Answers: 0

    I forgot to mention, this is with DataTables 1.10.12 on the newest version of chrome.

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    I sounds like you are using an older version of Buttons. Could you try the current 1.2.2 release please, which already has this issue resolved.

    Allan

  • TylerCTylerC Posts: 3Questions: 0Answers: 0

    Thanks Allan. I didn't realize I was using an older release; the most current version of DataTables on Nuget (1.10.12) has buttons version 1.2.0.

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    The NuGET packages are not maintained by myself I'm afraid. Its up to the author of those packages to track the DataTables releases.

    Allan

This discussion has been closed.