javascript - 如何使用语言文件添加数据表按钮?
问题描述
我尝试使用带有提取按钮的翻译文件,但没有成功
这是我的代码:
$(document).ready(function(){
var table = $('#table').DataTable({
"columnDefs": [{"orderable": false, "targets": 5}],
"order": [1, "desc"],
"oLanguage": { "sUrl": "/public/us.txt" },
buttons: [{
extend: 'csv',
text: '<i class="fa fa-download"></i> Export to CSV',
title: 'Data export - <?= date("YmdHi") ?>',
className: 'btn-sm',
exportOptions: { columns: [0, 1, 2, 3, 4, 5] }
},{
extend: 'excel',
text: '<i class="fa fa-download"></i> Export to Excel',
title: 'Data export - <?= date("YmdHi") ?>',
className: 'btn-sm',
exportOptions: { columns: [0, 1, 2, 3, 4, 5] }
}]
});
table.buttons().container().appendTo( '.button-container' );
});
问题是当我添加该行时"oLanguage": { "sUrl": "/public/us.txt" }
按钮没有出现并且我在谷歌控制台中没有错误
编辑 :
我们.txt:
{
"sEmptyTable": "No data available in table",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
"sInfoEmpty": "Showing 0 to 0 of 0 entries",
"sInfoFiltered": "(filtered from _MAX_ total entries)",
"sInfoPostFix": "",
"sInfoThousands": ",",
"sLengthMenu": "_MENU_ entries",
"sLoadingRecords": "Loading...",
"sProcessing": "Processing...",
"sSearch": "",
"searchPlaceholder": "Search ...",
"sZeroRecords": "No matching records found",
"oPaginate": {
"sFirst": "First",
"sLast": "Last",
"sNext": "Next",
"sPrevious": "Previous"
},
"oAria": {
"sSortAscending": ": activate to sort column ascending",
"sSortDescending": ": activate to sort column descending"
}
}
解决方案
推荐阅读
- .htaccess - 尝试缓存半身像时,从查询字符串方法移开后,样板无法获取 css/js
- ios - 为什么 viewDidLoad() 中不存在 TableView 的 FooterView 以及如何解决?
- python - ImportError:没有名为 Window 的模块,但来自导入工作
- python - Jupyter-notebook 在命令 conda install -c conda-forge 后爆炸
- node.js - 车把,每个都嵌套有平行阵列
- ios - 如何从呈现为半模态的视图控制器将视图控制器推送为全屏
- javascript - 快速排序 Lomuto 算法
- angularjs - ./ansi-html 1:0 中的错误模块解析失败:意外字符“#”(1:0)
- angular - 关闭按钮的 Jasmine 测试用例
- visual-studio-2017 - Visual Studio 调试菜单已禁用