我有两个数据表共享相同的jquery dataTables js,因为我无法在JavaScript文件中更改它,有没有其他方法可以更改它
我想将默认错误消息自定义为我自己的错误消息。
未找到匹配的记录-我们尚未添加任何内容表中没有可用的数据-没有您选择的数据。
检查设置自定义消息的选项。
$(document).ready(function() {
$('#data_table_id').DataTable( {
"language": {
"lengthMenu": "Display -- records per page",
"zeroRecords": "No matching records found - We don't add anything yet No data available in table - no data of your choice.",
"infoEmpty": "No records available"
}
} );
} );
请参阅此处http://datatables.net/usage/i18n编辑默认数据表文本。这里还有一个例子http://datatables.net/examples/basic_init/language.html
您也可以在initComplete
中这样做。它在添加自定义类和设计方面更灵活
"initComplete": function(settings, json) {
$('.dataTables_empty').html("<span class='label label-danger'>No records found</span>");
}
我使用的是Datatable 1.10.12,下面的代码适用于我:
"language": {
"processing": '<div class="widget-loader" id="loader"><div class="load-dots"><span></span><span></span><span></span></div></div>',
// show when no record found in a table...
"emptyTable": '<h4 class="block text-center"><i class="fa fa-exclamation-triangle" style="color: #C49F47;"></i> {{ __("no_record_found") }}</h4>',
// shown when no matching row found in filtering...
"zeroRecords": '<h4 class="block text-center"><i class="fa fa-exclamation-triangle" style="color: #C49F47;"></i> {{ __("no_record_found") }}</h4>'
}
请参阅:如何在Datatables 中显示空数据消息