Export columns from source, not displayed

Export columns from source, not displayed

InterregCEInterregCE Posts: 1Questions: 1Answers: 0

I have a table where i have concatenated several columns from the database into a single column in the displayed table.
But for the export i would like to have the columns from the source data and not the concatenated string shown in the table

Table data:

      { data: null, render: function ( data, type, row ) {
                return data.street+' '+data.house_number+' '+data.zip_code+' '+data.city+' '+data.countrycode;
            }
      }

Button:

{
    extend: 'excelHtml5',
    exportOptions: {
                        columns: ':visible'
                }
},

Here the address is displayed as one string in the table, but i would want the export to have all 5 columns (street, house_number, zip_code, city and countrycode) in separate columns

I came across the orthogonal data in the forums here, but i am not sure if it is possible for the export have more columns than the data displayed in the table.

Answers

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    I would look at adding those as hidden columns using columns.visible. You can then export those and ignore the rendered column. I like using columns.className to add a class to the columns to export and use that in the exportOptions.

    Kevin

This discussion has been closed.