Export buttons are behaving like type display.

Export buttons are behaving like type display.

IsaacBenIsaacBen Posts: 35Questions: 8Answers: 4

I want to format the exported text, but for some reason on export it's still type "display". This is very weird and didn't happen to me before.
I'm using this CDN:
https://datatables.net/download/#bs-3.3.7/jq-2.2.4/jszip-2.5.0/pdfmake-0.1.18/dt-1.10.13/b-1.2.4/b-colvis-1.2.4/b-html5-1.2.4/b-print-1.2.4

function numberFormat( data, type, row ) {
    console.log(type); //Always type display, even when exporting. 
    if (type === 'display' && data && data !== '') {
        return '$' + data;
    }
    if (type === 'export' && data) {
        return data;
    }
    return data;
};

Basic button definition:

buttons: [
    {
        extend: 'excelHtml5',
        title: 'Companies Round',
        exportOptions: {
            columns: ':visible'
        }
    },
    {
        extend: 'pdf',
        title: 'Companies Rounds',
        exportOptions: {
            columns: ':visible'
        }
    }
],

This question has an accepted answers - jump to answer

Answers

  • IsaacBenIsaacBen Posts: 35Questions: 8Answers: 4

    Adding this option solved it, but still weird. I have it working without it in another app. At least I think it works :smile:

    orthogonal: 'export'
    
  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin
    Answer ✓

    I'm not sure why it would work else where without that (perhaps a default being set?), but yes, the orthogonal option will default to be display so it matches what is displayed in the table.

    Allan

This discussion has been closed.