Skip to content

Commit d645c0a

Browse files
committed
Fix: Header and footer data from -api buttons.exportData() was not being passed through the formatting options
https://datatables.net/forums/discussion/78366/
1 parent 1448ef4 commit d645c0a

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

js/dataTables.buttons.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,9 +2646,15 @@ var _exportData = function (dt, inOpts) {
26462646

26472647
var data = {
26482648
header: header,
2649-
headerStructure: dt.table().header.structure(config.columns),
2649+
headerStructure: _headerFormatter(
2650+
config.format.header,
2651+
dt.table().header.structure(config.columns)
2652+
),
26502653
footer: footer,
2651-
footerStructure: dt.table().footer.structure(config.columns),
2654+
footerStructure: _headerFormatter(
2655+
config.format.footer,
2656+
dt.table().footer.structure(config.columns)
2657+
),
26522658
body: body
26532659
};
26542660

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

2668+
function _headerFormatter(formatter, struct) {
2669+
for (var i=0 ; i<struct.length ; i++) {
2670+
for (var j=0 ; j<struct[i].length ; j++) {
2671+
var item = struct[i][j];
2672+
2673+
if (item) {
2674+
item.title = formatter(
2675+
item.title,
2676+
j,
2677+
item.cell
2678+
);
2679+
}
2680+
}
2681+
}
2682+
2683+
return struct;
2684+
}
2685+
26622686
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
26632687
* DataTables interface
26642688
*/

0 commit comments

Comments
 (0)