$(document).ready(function() {
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
} );
} );
我正在使用bootstrap数据表,点击pdf按钮在pdf文件中无法正确显示阿拉伯语单词。
答案 0 :(得分:-1)
$("#example").dataTable({
"fnDrawCallback": function (oSettings) {
if ($('#tblList tr').length < 11) {
$('.dataTables_paginate').hide();
}
},
"bInfo": false,//Hide H"Showing 1 of N Entries" When user search
"iDisplayLength": @GlobalVars.PageRowsCount,
"order": [], // Disable Default Sort
"pagingType": "full_numbers",
"dom": "<'row'<'col-sm-3'l><'col-sm-6 text-center'B><'col-sm-3'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
buttons: [
{
extend: 'print',
text: 'طباعة',
key: {
key: 'p',
altkey: true,
},
customize: function (win) {
$(win.document.body).css("direction", "rtl");
$(win.document.body).find('tr td:lastchild').css("display",
"none");
$(win.document.body).find('tr th:last-child').css("display",
"none");
$(win.document.body).find('h1').css("visibility", "visible");
$(win.document.body).find('h1').css("text-align", "center");
$(win.document.body).find('h1').css("margin", "30");
}
}
,{
extend: 'excel',
text: 'تصدير للإكسل',
key: {
key: 'x',
altkey: true
}
}
,{
extend: 'pdfHtml5',
text: 'تصدير لـ PDF',
key: {
key: 'f',
altkey: true
}
}
],
"columnDefs": [{
"targets": $("#tblList").find('tr')[0].cells.length-1, // dont sort
or search last column (Actions Column)
"searchable": false,
"orderable": false
}],
"oLanguage": {
"oPaginate": {
"sFirst": "الأولى",
"sPrevious":"السابق",
"sNext": "التالي",
"sLast": "الأخيرة"
},
"sSearch": "بحث _INPUT_",
"sZeroRecords": "لا توجد بيانات",
"sInfo": "صفحة _PAGE_ من _PAGES_",
"sLengthMenu": 'عرض'+
'<select class= "custom-select custom-select-sm form-control
form-control-sm" > ' +
'<option value="10">10</option>' +
'<option value="20">20</option>' +
'<option value="50">50</option>' +
'<option value="-1">الكل</option>' +
'</select> سجلات'enter code here
}
});
});