Server side export all problem

Server side export all problem

pw27pw27 Posts: 19Questions: 3Answers: 0

Hi..
I've seen a few discussions on this, but not my specific query.

I'm using server side, as client side it takes around 30 seconds to load the big table (30000 rows).

I realise that the export buttons only work for visible data for server side, so I added a "-1" to lengthMenu to get a full table download. That takes a few seconds, which is fine.

However, if I now click any of the export buttons, Chrome racks up a lot of cpu use, but never completes the export.
I assumed that, with the full table loaded locally, the export would work the same as with client side operation?
Using DT 1.13.7

Setup as below...

Any ideas?

Thanks

Pete.

new DataTable('#myTable', {
    ajax: 'scripts/server_processing.php',
    processing: true,
    serverSide: true,
      "pageLength": 25,
        "lengthMenu": [ 15, 25, 50, 75, 100, -1 ],
        dom: 'Blfrtip',
        buttons: [  'copy', 'csv', 'excel', pdf', 'print'
        ],
      "deferRender": true,
    "language": {
    "infoFiltered": ""
    }       
    });

Answers

  • rf1234rf1234 Posts: 2,932Questions: 87Answers: 415

    Try without "deferRender" please. That is usually only needed without "serverSide". If you want to do a full table download you would need everything to rendered for export, I guess.

  • pw27pw27 Posts: 19Questions: 3Answers: 0

    Good point, that was left over in error!
    However, it makes no difference.
    I added some extra lengthMenu items...

    2500 lines exports in a couple of seconds.
    5000 lines - and it fails.

    Curious.

  • pw27pw27 Posts: 19Questions: 3Answers: 0

    Further experiment - on two different servers - 2800 works, 2850 fails!

  • pw27pw27 Posts: 19Questions: 3Answers: 0

    And, sanity check, if I revert to client side, it works fine.

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

    I assumed that, with the full table loaded locally, the export would work the same as with client side operation?

    Correct. Of course, the only thing server-side processing would be doing at this point is introducing network latency. If you know the end user is going to do this, then you should just load them all up front.

    If you could link to a page showing the issue I might be able to help debug it a bit. Which export is failing? CSV is the lightest, PDF the heaviest.

    Allan

  • pw27pw27 Posts: 19Questions: 3Answers: 0
    edited January 8

    They all fail, copy, pdf, csv, excel... at the same point, ok at 2800 entries, not at 2850!
    Can't help feel it's something dumb I'm doing but I can't see it!

  • pw27pw27 Posts: 19Questions: 3Answers: 0

    I sent login on a DM to you.

  • pw27pw27 Posts: 19Questions: 3Answers: 0

    Refined it slightly - 2811 works, 2812 fails. I'd hoped the actual number might be clue...

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

    Hi,

    Thanks for the PM with the link!

    In the console I see the error "too much recursion" which appears to be happening where it is attempting to strip HTML for the export.

    Could you try changing:

            buttons: [
                'copy', 'csv', 'excel', 'pdf', 'print'
            ],
    

    To be:

    {
      buttons: [
        { extend: "copy", exportOptions: { decodeEntities: false } },
        { extend: "csv", exportOptions: { stripHtml: false } },
        { extend: "excel", exportOptions: { stripHtml: false, decodeEntities: false } },
        "pdf",
        "print",
      ];
    }
    

    Bit experimental, but let's see the impact of those options.

    Allan

  • pw27pw27 Posts: 19Questions: 3Answers: 0
    edited January 9

    That works a treat!
    Runs at all 23000 lines now.
    Thanks!
    I'll run some more exhaustive tests but it looks fine.

    A quick aside - is there an easy way to add some sort of "loading" spinner or similar while it renders all the lines. It's only a few seconds but it would be nice, if it's easy!

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

    You could use the processing() plug-in (which will be built into DataTables 2).

    Out of interest, which of the combinations for stripHtml and decodeEntities did you go with? The decodeEntities is the slow one. I've got a change for Buttons 3 that will improve performance there.

    Allan

  • pw27pw27 Posts: 19Questions: 3Answers: 0

    Thanks for the plug in reference.
    It was striphtml that was the problem, it worked with just that one set to false.
    decodeentities on it's own didn't do it.

    Many thanks for all the help!

Sign In or Register to comment.