Table Control Not working - Also Excel Export and CSV Export Run only if clicked initially

Table Control Not working - Also Excel Export and CSV Export Run only if clicked initially

AmbientAmbient Posts: 23Questions: 9Answers: 0

Link to test case: SAYING BIN TO LARGE TO SAVE

No DEbugger code

NO Error messages

THE Javascript has been run through a validator and has no syntax errors.

The Footer not working.
Button show.
Control doesn't work.
PDF does
Print does
Copy does

Export to csv will work when first run and not after

Export to Excel will work on first run but not after.

Search stopped working and column ordering stopped working.


$(document).ready(function () { var currentDate = new Date(); var day = currentDate.getDate(); var month = currentDate.getMonth() + 1; var year = currentDate.getFullYear(); var d = day + "-" + month + "-" + year; var printCounter = 0; var pageTotal = 0; var total = 0; // Append a caption to the table before the DataTables initialisation $('#giftcards').append('<caption style="caption-side: bottom">Opus Retail Solutions\'s Gift Card table. Ran on ' + d + '</caption>'); $('#giftcards').DataTable({ dom: 'Bfrtip', buttons: [ // ADD A Function for removing column visibility { extend: 'collection', text: 'Table control', buttons: [ { text: 'Toggle Created Date', action: function(e, dt) { dt.column(-2).visible(!dt.column(-2).visible()); } }, { text: 'Toggle Expiry Date', action: function(e, dt) { dt.column(-3).visible(!dt.column(-3).visible()); } }, { collectionTitle: 'Visibility control', extend: 'colvis', collectionLayout: 'two-column', } ], fade: true }, // End Function column visibility // COPY TO CLIPBOARD BELOW { extend: 'copyHtml5', footer: true, messageTop: 'Opus Retail Solutions Gift Cards Report.', text: '<u>C</u>opy', key: { key: 'c', altKey: true, } }, { extend: 'excelHtml5', filename: 'Gift_cards_' + d, text: 'E<u>x</u>cel', key: { key: 'x', altKey: true, test: 'Save current page', exportOptions: { modifier: { page: 'current' } } } }, { extend: 'csvHtml5', footer: true, filename: 'Gift_cards_' + d, text: 'Export CSV', messageTop: 'Opus Retail Solutions Gift Cards Report.', }, { extend: 'pdfHtml5', footer: true, filename: 'Gift_cards_' + d, messageTop: 'Opus Retail Solutions Gift Cards Report.' + d, download: 'open', // Append AN IMAGE customize: function(doc) { console.log(doc.content); //header:'simple text', //pdf.setFont( FontFamily.Verdana ); doc.watermark = {text: 'Opus Retail Solutions', color: 'grey', opacity: 0.1}; doc.content.splice(1, 0, { margin: [0, 0, 0, 12], alignment: 'right', image: 'data:image/jpeg;base64,'data', width: 200, height: 120, }); } }, { extend: 'print', footer: true, //messageTop: 'Opus Retail Solutions Gift Cards Report' + d, messageTop: function() { printCounter++; if (printCounter === 1) { return 'This is the first time you have printed this document.'; } else { return 'You have printed this document ' + printCounter + ' times'; } }, messageBottom: null }, ], "pageLength": 25, "footerCallback": function() { var api = this.api(); // Remove the formatting to get integer data for summation var intVal = function(i) { return typeof i === 'string' ? i.replace(/[\$,]/g, '') * 1 : typeof i === 'number' ? i : 0; }; // Total over all pages total = api .column(5) .data() .reduce(function(a, b) { return intVal(a) + intVal(b); }, 0); // Total over this page pageTotal = api .column(5, { page: 'current' }) .data() .reduce(function(a, b) { return intVal(a) + intVal(b); }, 0); // Update footer $(api.column(5).footer()).html( '$' + pageTotal + ' ( $' + total + ' total)' ); } }); });

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,118Questions: 1Answers: 2,583
    Answer ✓

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. 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

This discussion has been closed.