Is it possible to include the rowId when exporting?

Is it possible to include the rowId when exporting?

lmartinezlmartinez Posts: 8Questions: 5Answers: 2

I am trying to use the export abilities from datatables, instead of trying accomplish this server side. I am trying to include the RowId in my export because I will need it offline but I am having trouble including it. I know there is an export options that i can use but it is not working for me.

This is the beginning of my Columns initialization

     columns: [
            {
                data: 'DT_RowId',
                //targets: 0,
                orderable: false,
                searchable:false,
                checkboxes: {
                    selectRow: true
                }
            },
            { data: "ManufacturerName", visible: false },

and this is how i defined my button

            {
                extend: 'excel',
                className: 'm-1 btn-sm d-none exportButton',
                text: 'Export All',
                exportOptions: {
                    columns: [0, 1, 2,3,4,8,12,13,14,15,16,17,18,26,27]
                }
            }

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    That should work correctly. Could you link to a page showing the issue please?

    Thanks,
    Allan

  • lmartinezlmartinez Posts: 8Questions: 5Answers: 2
    Answer ✓

    So I created a workaround for this, I basically added the row Id into another separate column. I didn't put two and two together and didn't realize that it was only exporting what is getting rendered, until I added another column which was rendered a certain way.

    So I did some research and came across orthogonal and I included it in my code. Now it works as intended.

                            extend: 'excelHtml5',
                            className: 'm-1 btn-sm optionExportButton d-none',
                            text: 'Export',
                            title: null,
                            exportOptions: {
                                columns: [47, 1, 2, 3, 4, 5, 8, 12, 13, 14, 15, 16, 17, 18, 26, 27, 28, 29, 38, 39],
                                orthogonal: {
                                    display: 'export'
                                },    
                            },
                            customize: function (xlsx) {
                                var sheet = xlsx.xl.worksheets['sheet1.xml'];
    
                                $('row:not(:first) c[r^="A"]', sheet).attr('s', '7');
                            }
    
This discussion has been closed.