Tabletools copy/export not working for checkbox rendered column

Tabletools copy/export not working for checkbox rendered column

crush123crush123 Posts: 417Questions: 126Answers: 18
edited June 2015 in TableTools

i have a datatable which is rendering 1 and 0 values as checkboxes.

everything works fine, but if i want to copy/export with tabletools, the rendered column is ignored (print is ok)

so if i have

        { data: "tblorders.PaymentBanked" ,
        render: function ( data, type, row ) {

            return data;
        },
        className: "dt-body-center"
        },}

The copy export is ok, but if i have

        { data: "tblorders.PaymentBanked" ,
        render: function ( data, type, row ) {
            if ( type === 'display' ) {
                return '<input type="checkbox" class="editor-tblorders_PaymentBanked" disabled="disabled">';
            }
            return data;
        },
        className: "dt-body-center"
        }

the column is ignored.

As a side issue, is it possible to export unrendered data to excel, so for example data which is rendered on screen as currency, just to export as a number ?

thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,572Questions: 1Answers: 10,482 Site admin
    Answer ✓

    So the problem here is that the display option of your render method is returning HTML, but since HTML isn't all that useful in the exported files, TableTools will strip the HTML - hence why it looks like you get nothing!

    What you really want, I think here, is to remove the display parameter passed in on this line if you are using a local version of TableTools.

    I'm working on a rewrite of this functionality at the moment and plan to make this option configurable!

    Regards,
    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18

    That helps, but unfortunately gives me no fine control.

    Also means that concatenated field such as firstname + lastname is rendered as [object Object] in excel.

    will try and come up with a different workaround

    Thanks

  • crush123crush123 Posts: 417Questions: 126Answers: 18
    edited June 2015

    using the sample on

    http://www.datatables.net/extensions/tabletools/button_options

    I created hidden duplicate columns with unrendered content in my datatable, and used mColumns to determine which columns to export

    ;-)

  • allanallan Posts: 63,572Questions: 1Answers: 10,482 Site admin

    Nice work around :-)

    The new Buttons extension will give the option to define a custom orthogonal data request - so you could request export data for example.

    Allan

This discussion has been closed.