首先,我的主要目的是在某些列总和显示页脚区域中添加并增加透明度。所以我习惯了页脚回调函数。好的,这里没有问题。然后使用pdf按钮导出数据表信息。 İt可以正常工作并在浏览器上完美显示,但是当我导出pdf时,不要工作
HTML标记不正确。
我该怎么办?出问题了...
下面的我的脚号代码
标签不起作用,并显示内联和导出的pdf文件脚。
$( $this.api().column( 10 ).footer()).empty();
_.each(oIT, function(v, i){
var txt = "<span style='display:block; font-size:14px;'>" + v + "</span> <br/>";
$( $this.api().column( 10 ).footer()).append(txt);
});
我想在与下面相同的pdf脚区域上显示
159,954.12
$ 1,654.00
£500.00
€111.00
下面的我的js代码
<script>
$(document).ready(function() {
var table = $('#example').dataTable({
footerCallback: function(row, data, start, end, display){
var $this = this;
// Important to convert number in float
var convertFloat = function(num) {
var value = typeof num === 'string' ? num.replace(/[\$,]/g, '.') : typeof num === 'number' ? num : 0;
return Number(value);
}
var moneyFormat = function(num, c){
var p = num.toFixed(2).split(".");
return c + p[0].split("").reverse().reduce(function(acc, num, i, orig) {
return num=="-" ? acc : num + (i && !(i % 3) ? "," : "") + acc;
}, "") + "." + p[1];
}
var totalFunction = function(current){
var api = $this.api();
var r = api.column(9, {page: current}).data();
var ia = api.column(10, {page: current}).data();
var c = api.column(11, {page: current}).data();
var oR = [];
var oI = [];
var oRT = [];
var oIT = [];
_.each(r, function(v, i){
oR.push({
value: v,
currency: c[i]
});
oI.push({
value: ia[i],
currency: c[i]
});
});
//############### Rez Functions ###############
var gOR = _.groupBy(oR, 'currency');
var i = 0;
_.each(gOR, function(value, index){
var total = value.reduce(function(a, b){
return convertFloat(a) + convertFloat(b.value);
}, 0);
oRT[i] = moneyFormat(total, index);
i++;
});
// Rez tutar column
$( $this.api().column( 9 ).footer()).empty();
_.each(oRT, function(v, i){
var txt = "<span style='display:block; font-size:14px;'>" + v + "</span> <br>";
$( $this.api().column( 9 ).footer()).append(txt);
});
//################# End Rez Functions ##############
//########## Iade Functions ############
var gOI = _.groupBy(oI, 'currency');
var y = 0;
_.each(gOI, function(value, index){
var total = value.reduce(function(a, b){
return convertFloat(a) + convertFloat(b.value);
}, 0);
oIT[y] = moneyFormat(total, index);
y++;
});
// Iade tutar column
$( $this.api().column( 10 ).footer()).empty();
_.each(oIT, function(v, i){
var txt = "<span style='display:block; font-size:14px;'>" + v + "</span> <br/>";
$( $this.api().column( 10 ).footer()).append(txt);
});
//########## End Iade Functions ###########
}
var current = false;
// Initialize the functions
totalFunction(current);
$(".dataTables_filter .input-sm").on('input', function(){
var input = $(this).val();
if(input == ""){
current = false;
}else{
current = 'current';
}
totalFunction(current);
});
},
dom: 'Bfrtip',
buttons: [
{
extend: 'colvis',
text: 'Kolonlar'
},
{
extend: 'excelHtml5',
text: 'EXCEL',
filename: 'Iade_Liste',
orientation: 'landscape',
pageSize: 'LEGAL',
footer: true,
exportOptions: {
columns: ':visible',
stripNewlines:"\n",
stripHtml:true,
}
},
{
extend: 'pdfHtml5',
text: 'PDF',
filename: 'Iade_Liste',
orientation: 'landscape',
pageSize: 'A4',
footer: true,
exportOptions: {
columns: ':visible'
}
},
],
processing: false,
serverSide: false,
ajax: 'server.php',
paging: true
} );
} );
</script>