Can Datatable Customize Export Column?
Can Datatable Customize Export Column?
hooix0013
Posts: 17Questions: 5Answers: 0
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
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
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
Hidden columns is definitely the way to go. Out of interest, why do you say that's not possible?
Colin
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?
Yes.
You can also select which columns column visibility can toggle.
Allan