Print selected demo not working

Print selected demo not working

sa656sa656 Posts: 2Questions: 1Answers: 0

Hi

I'm new to this so probably not the place to ask it but I'm looking at doing export (excel, pdf, print) buttons for selected rows only on my table but the demo on the below page seems to have stopped working?

https://datatables.net/extensions/buttons/examples/print/select.html

Cheers

This question has accepted answers - jump to:

Answers

  • AGladwinAGladwin Posts: 4Questions: 1Answers: 1
    Answer ✓

    I have noticed that too. I've been trying to copy only selected rows using the latest version of the table, and the select and buttons extensions - but it doesn't work for me either. I checked the example to see if I was doing something wrong, but as the example doesn't work either I guess it's not something I've done.

  • sa656sa656 Posts: 2Questions: 1Answers: 0

    Just heard from Allan and there might be a patch out Monday for it

  • modulusOperatormodulusOperator Posts: 7Questions: 0Answers: 1

    I found where the problem is occurring (or at least a symptom of the problem that is causing this issue) and made a fix, but.... WARNING: there could be unintended consequences of my fix, use at your own risk. My fix seems to work in my use case, when selecting rows to then export using the Buttons extension. For my use case the following has allowed me to export selected rows:
    In the Select extension at line ~580 I changed:

    if ( (selected === true && data._select_selected === true) ||
         (selected === false && ! data._select_selected ) ) 
    {
        out.push( indexes[i] );
    }
    

    to:

    if (o.type === "row") {
        if ( (selected === true && data._select_selected === true) ||
             (selected === false && ! data._select_selected ) ) 
        {
            out.push( indexes[i] );
        }
    } else if (o.type === "column") {
        out.push( indexes[i] );
    }
    

    Again, this may not be the best fix, may only be fixing a symptom of an underlying problem, and could cause unintended consequences, use at your own risk.

  • allanallan Posts: 63,210Questions: 1Answers: 10,415 Site admin
    Answer ✓

    Hi,

    This issue was fixed by this commit is Buttons. It will be included in the 1.0.4 release and is in the nightly version if you want to use it there.

    Regards,
    Allan

This discussion has been closed.