Can Datatable Customize Export Column?

Can Datatable Customize Export Column?

hooix0013hooix0013 Posts: 17Questions: 5Answers: 0
edited October 2022 in Free community support

Can we add new column into the export page? Because I have many columns came with combined data e.g:
My columns header:

<th>Name /<br />Age</th>

This is how my columnDefs looks like:

columnDefs:[{
        "render": function(data, type, meta) {
                 return data.Name + "<br/>" + data.Age;
         }
}]

And I want them to be in separated columns when come to export. How can I achieve it? I can't use hidden columns to decide which to show because they are too many columns. Thank in Advance!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin

    Have a second column which is hidden (columns.visible) but included in the export - that could be the age column. Then for the first column have your rendering function return just the name for the export - see this example for orthogonal data export.

    Allan

  • hooix0013hooix0013 Posts: 17Questions: 5Answers: 0

    I cant use (columns.visible) in this case since there were many columns. Can I declare two parts of columnDef? one for normal display and one for export

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited October 2022

    Hidden columns is definitely the way to go. Out of interest, why do you say that's not possible?

    Colin

  • hooix0013hooix0013 Posts: 17Questions: 5Answers: 0

    Hii Colin, Because when come to colvis, there's too many option in the menu duplicate and user cant accept that... Is there anyway to customize the export columns so that i can decide which column to put instead of following what original table show?

  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin
    Answer ✓

    customize the export columns so that i can decide which column to put instead of following what original table show?

    Yes.

    You can also select which columns column visibility can toggle.

    Allan

This discussion has been closed.