Table data is blank in all exports

Table data is blank in all exports

AzuraXvAzuraXv Posts: 3Questions: 1Answers: 0

Hello, I've got a table where I use a lot of:
render: function(data, type, row, meta) {}
for editing data and rendering in right format.

I also use:
drawCallback: function(settings, json) {}
for deleting some rows after render.

All things are working fine until i try to export. Here is image of my table:

But when I try to export (for example to excel) some data is missing. And it's missing for the columns where i use render function, it's really weird:

I can't provide a test case, but I hope someone can help me. THANKS!

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Yep, we'll need to see that. You don't need to use production data, just something that demonstrates the configuration. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • AzuraXvAzuraXv Posts: 3Questions: 1Answers: 0
    edited October 2021

    Okay, I've tried, but it's weird, here it says "processing" but on my page it's showing the table correctly (but the export is not working)

    I've provided really short version of my code, but I know that error is in these lines of code:

    nodes.forEach(function(node) {
    table.row(node).remove().draw();
    });

    If i comment them, I can export and no data is missing, everything is fine, except I NEED to delete those table rows...

    http://live.datatables.net/pivejeqe/1/

  • allanallan Posts: 63,488Questions: 1Answers: 10,467 Site admin

    If you pop open the console in your browser you'll see the script is throwing an error:

    Uncaught ReferenceError: previousRow is not defined

    It is referring to this line in the drawCallback you are using:

    if (previousRow.u_user_id !== undefined && previousRow.u_user_id !== null) {
    

    And indeed, previousRow is undefined at that point.

    Adding var previousRow = {}; at the top of the draw callback function resolves that error.

    Allan

  • AzuraXvAzuraXv Posts: 3Questions: 1Answers: 0

    Oh, I see, but that's not the problem. I just forgot including it.
    The problem is that when I dont remove rows with this:
    nodes.forEach(function(node) {
    table.row(node).remove().draw();
    });

    Everything is working, but when i remove the rows the table is showing perfectly but in the export the data is missing :/

  • kthorngrenkthorngren Posts: 21,315Questions: 26Answers: 4,948

    I updated your test case to include Allan's fix and the Buttons library.
    http://live.datatables.net/pivejeqe/4/edit

    It used the Excel export and all the columns for the one remaining row are in the exported file. Please update the test case or provide the steps need to show the problem.

    Kevin

Sign In or Register to comment.