当搜索返回“找不到匹配的记录”时,如何在jQuery DataTables中将aLengthMenu更改为0和Show [0] entries
?
请参阅this example并尝试在搜索框中输入不存在的文字。
答案 0 :(得分:1)
你有两种方法可以做到这一点。
按档案
$('#myTable').DataTable({
"language": {
"url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json"
}
});
手动翻译
$('#myTable').DataTable({
"language": {
"emptyTable": "No hay datos disponibles",
"info": "Mostrando _START_ de _END_ de un total de _TOTAL_ entradas",
"infoEmpty": "Mostrando 0 de 0 de un total de 0 entradas",
"infoFiltered": "(filtrado de un total de _MAX_ total entradas)",
"infoPostFix": "",
"thousands": ".",
"lengthMenu": "Mostrar _MENU_ entradas",
"loadingRecords": "Cargando...",
"processing": "Procesando...",
"search": "Buscar:",
"zeroRecords": "No se encontraron datos",
"paginate": {
"first": "Primera",
"last": "ÚLtima",
"next": "Siguiente",
"previous": "Anterior"
},
"aria": {
"sortAscending": ": activate to sort column ascending",
"sortDescending": ": activate to sort column descending"
}
}
});
您可以在my blog上查看我的帖子,其中包含基本用法和配置。有jsFiddle的例子
答案 1 :(得分:0)
<强>解强>
您可以使用infoCallback
选项定义在即将显示表信息时将调用的函数。
var table = $('#example').DataTable({
"infoCallback": function(settings, start, end, max, total, pre){
// If there are some records to display
if(total > 0){
return "Showing " + start + " to " + end + " of " + total + " entries" +
((total !== max) ? " (filtered from " + max + " total entries)" : "");
// Otherwise, if no records to display
} else {
return "";
}
}
});
<强>样本强>
请参阅this jsFiddle以获取代码和演示。