Skip to content

Commit

Permalink
Fix: Header and footer data from -api buttons.exportData() was not …
Browse files Browse the repository at this point in the history
…being passed through the formatting options

https://datatables.net/forums/discussion/78366/
  • Loading branch information
AllanJard committed Mar 4, 2024
1 parent 1448ef4 commit d645c0a
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions js/dataTables.buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -2646,9 +2646,15 @@ var _exportData = function (dt, inOpts) {

var data = {
header: header,
headerStructure: dt.table().header.structure(config.columns),
headerStructure: _headerFormatter(
config.format.header,
dt.table().header.structure(config.columns)
),
footer: footer,
footerStructure: dt.table().footer.structure(config.columns),
footerStructure: _headerFormatter(
config.format.footer,
dt.table().footer.structure(config.columns)
),
body: body
};

Expand All @@ -2659,6 +2665,24 @@ var _exportData = function (dt, inOpts) {
return data;
};

function _headerFormatter(formatter, struct) {
for (var i=0 ; i<struct.length ; i++) {
for (var j=0 ; j<struct[i].length ; j++) {
var item = struct[i][j];

if (item) {
item.title = formatter(
item.title,
j,
item.cell
);
}
}
}

return struct;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* DataTables interface
*/
Expand Down

0 comments on commit d645c0a

Please sign in to comment.