Failed to export data using the buttons and my custom button not showing

Failed to export data using the buttons and my custom button not showing

zammalekzammalek Posts: 4Questions: 1Answers: 0
edited August 20 in Free community support

Link to test case: https://live.datatables.net/fewukika/1/edit?html,css,js,console,output
Debugger code (debug.datatables.net): atokur
Error messages shown: TypeError: Cannot read properties of undefined (reading 'cell')
at X.<anonymous> (dataTables.min.js:4:61614)
Description of problem: Please help. Everything else is working fine except for my buttons.

For a start, my custom button is not showing but for the export buttons, even though I only select Copy, Excel and Print, it also show the CSV and PDF buttons.

Secondly, when I click on the buttons, it shows error on console

TypeError: Cannot read properties of undefined (reading 'cell') at X.<anonymous> (dataTables.min.js:4:61614) at X.iterator (dataTables.min.js:4:47573) at X.<anonymous> (dataTables.min.js:4:61527) at X.<anonymous> (dataTables.min.js:4:49267) at X.footer (dataTables.min.js:4:48525) at X.<anonymous> (dataTables.buttons.min.js:4:25274) at X.map (<anonymous>) at X.map (dataTables.min.js:4:47785) at u (dataTables.buttons.min.js:4:25238) at X.<anonymous> (dataTables.buttons.min.js:4:23735)

Thanks in advance.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,116Questions: 1Answers: 10,397 Site admin
    Answer ✓

    Your example doesn't appear to run due to invalid Javascript (there are HTML tags in there).

    The error, I think, might come from a difference between the number of cells in the header and the Javascript declaration. But I'd need a running test case that shows the issue to be sure.

    Allan

  • zammalekzammalek Posts: 4Questions: 1Answers: 0
    edited August 20

    OK. I solve my first problem.

    I accidentally declare the topStart twice where I should only declare the buttons. I have corrected as belows and now showing the right button.

    layout: { topStart: ['buttons', 'pageLength'] }, buttons: ['copy','excel','print', { text: 'Add New', ... }],

    but the export buttons still give the same error :(

  • zammalekzammalek Posts: 4Questions: 1Answers: 0

    thanks for replying so early.
    I will try to create a new test case later tonight.

  • zammalekzammalek Posts: 4Questions: 1Answers: 0

    You are right. My footer less one <th>. I did not add column for the action button as I did not total it.

    Now it is working.

    Thanks Allan.

  • allanallan Posts: 63,116Questions: 1Answers: 10,397 Site admin

    Awesome - great to hear you got it working!

    Allan

Sign In or Register to comment.