javascript 在数据表中找不到匹配的记录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22979435/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No matching records found in DataTable
提问by Mohaideen
I am using DataTable for retrieving the data from server side. Here. NO information on DataTable. It shows No matching records found error.
我正在使用 DataTable 从服务器端检索数据。这里。没有关于数据表的信息。它显示没有找到匹配的记录错误。
Here, oLanguage.sEmptyTable is not working and oLanguage.sZeroRecords is working refer http://datatables.net/ref#sZeroRecords
在这里,oLanguage.sEmptyTable 不起作用,oLanguage.sZeroRecords 正在工作,请参阅http://datatables.net/ref#sZeroRecords
var DataTableApp = $('#DataTableApp').dataTable({
"sAjaxSource": "php/getAppDetails.php",
"bRetrieve":true,
"bDestroy":true,
"bServerSide": true,
//"bProcessing": true,
"sAjaxDataProp": "aaData",
//"bDeferRender": true,
"sServerMethod": "POST",
"iTotalDisplayRecords":1,
"iTotalRecords":1,
"oLanguage": {
"sZeroRecords": "No records to displays"
},
"fnServerParams": function ( aoData ) {
var imei_app = document.getElementById('imei').value;
console.log(imei_app);
aoData.push({"name":"imei","value":imei_app});
},
//aoColumns
"aoColumns": [{
"mData": "appName"
}, {
"mData": "appId"
}, {
"mData": "versionInstalled"
}, {
"mData": "appSize"
}, {
"mData":"dataSize"
},{
"mData": "appType"
},{
"mData":"installedLocation"
},{
"mData": "installedTime"
}]
});
回答by AntonChanning
oLanguage.sEmptyTable
and oLanguage.sZeroRecords
(or in the latest format language.emptyTable
and language.zeroRecords
) have different purposes.
oLanguage.sEmptyTable
和oLanguage.sZeroRecords
(或最新的格式language.emptyTable
和language.zeroRecords
)有不同的目的。
language.emptyTable
Displays when the table contains no rows at all.language.zeroRecords
Displays when, after applying filters, there are now no records to display.
language.emptyTable
当表中根本不包含任何行时显示。language.zeroRecords
在应用过滤器后现在没有要显示的记录时显示。
It sounds like your table had rows before filters were applied.
听起来您的表格在应用过滤器之前有行。
回答by Jaykishan Soni
You need to add .dataTables_empty CSS class with display: noneattribute to your global style sheet (i.e. src/styles.css).
您需要将带有display: none属性的.dataTables_empty CSS 类添加到您的全局样式表(即src/styles.css)。
Note: in the angular, global style sheet is located at SCSS folder (i.e. scss/_custom.scss).
注意:在 angular 中,全局样式表位于 SCSS 文件夹(即scss/_custom.scss)。
.dataTables_empty {
display: none;
}
https://l-lin.github.io/angular-datatables/#/basic/server-side-angular-way
https://l-lin.github.io/angular-datatables/#/basic/server-side-angular-way