Issue on datatable export

Issue on datatable export

navinAcenavinAce Posts: 6Questions: 1Answers: 0
edited January 24 in Free community support

Answers

  • navinAcenavinAce Posts: 6Questions: 1Answers: 0

    body: function(data, row, column, node) {
    // Assuming the problematic column is at index 6 (seventh column)
    if (column === 6) {
    return data ? data : ''; // Force conversion to string to maintain the integrity of the 16-digit number
    }
    return data;
    }

  • navinAcenavinAce Posts: 6Questions: 1Answers: 0

    on the column 6 there are 16 digit value number, due to that when i export, the value is rounded off or any special character are added in the beginning of the 16 digit number.
    what can be the solution

  • allanallan Posts: 63,872Questions: 1Answers: 10,527 Site admin

    The test case doesn't appear to show a table or export buttons?

    Forcing the column to be a string sounds like a good plan though, although return data ? data : ''; doesn't appear to do that? data.toString() perhaps?

    Allan

  • navinAcenavinAce Posts: 6Questions: 1Answers: 0

    i almost tried this much thing non of them work
    return \${data}; output:2223703360068248
    return \u200B${data}; output: ​2223703360068248
    return data.toString(); output: 2223703360068250
    return "${data}"; output: "2223703360068248"
    return '${data}; output: '2223703360068248

  • allanallan Posts: 63,872Questions: 1Answers: 10,527 Site admin

    Can you update the test case to be running and show the issue so I can try to debug it?

    Allan

  • navinAcenavinAce Posts: 6Questions: 1Answers: 0
        var file_name = '<?php echo $file_name_excel ?>';
        $('#dynamic_table').DataTable({
            dom: 'Bifrtp',
            bPaginate: false,
            ordering: true,
            buttons: [{
                extend: 'excel',
                footer: true,
                title: file_name,
                className: 'excel-buttonNAD',
                exportOptions: {
                    columns: ':visible',
                    format: {
                        header: function(mDataProp, columnIdx) {
                            var htmlText = '<span>' + mDataProp + '</span>';
                            var jHtmlObject = jQuery(htmlText);
                            jHtmlObject.find('div').remove();
                            var newHtml = jHtmlObject.text();
                            return newHtml;
                        },
                        body: function(data, row, column, node) {
                            // Assuming the problematic column is at index 6 (seventh column)
                            if (column === 6) {
                                return `\`${data}`; // Force conversion to string to maintain the integrity of the 16-digit number
                            }
                            return data;
                        }
                    }
                }
            }, {
                className: 'colVisBAT',
                extend: 'colvis',
                text: 'Column Visibility',
                collectionLayout: 'fixed two-column'
            }]
        });
    

    the code is huge i cant make it running here.
    the problem is i have to upload the excel in a portial, which has 16 digit.
    we have to do something to make it to string
    because in number it is automatically rounding off.

  • kthorngrenkthorngren Posts: 21,571Questions: 26Answers: 4,996

    the code is huge i cant make it running here.

    We don't want the full code for a test case. The test case should be reduced done to the code and data that replicate the issue.

    the problem is i have to upload the excel in a portial, which has 16 digit.
    we have to do something to make it to string

    There are a couple different ways to try resolving this presented in this thread. Let us know if one of those helps. If you still need help then please provide a simple test case showing the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • navinAcenavinAce Posts: 6Questions: 1Answers: 0

    Ok, thanks i will check and let you know about the update

Sign In or Register to comment.