我有一个jquery数据表,其数据来自数据库,从java servlet获取。很少列有空值。因此我收到警告
DataTables警告:table id = lplist - 请求的未知参数' FeeCompany'第9行。有关此错误的详细信息,请参阅http://datatables.net/tn/4
我希望将这些空值替换为空字符串。有人请指导如何实现此目的。
我的代码段如下
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script
src="http://cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
<script
src="http://cdn.datatables.net/scroller/1.2.2/js/dataTables.scroller.min.js"></script>
<link
href="http://cdn.datatables.net/scroller/1.2.2/css/dataTables.scroller.css"
rel="stylesheet" type="text/css" />
<link href="http://cdn.datatables.net/1.10.4/css/jquery.dataTables.css"
rel="stylesheet" type="text/css" />
<title>Insert title here</title>
<script type="text/javascript">
$(document).ready(function () {
$("#lplist").dataTable({
"serverSide": true,
"sAjaxSource": "/JQueryDataTablesAll/CompanyGsonObjects",
dom: "rtiS",
scrollY: 450,
scrollX:true,
"processing": true,
"aoColumns": [
{ "mData": "InsuredName" },
{ "mData": "CustAddress_City" },
{ "mData": "CustAddress_State" },
{ "mData": "CustAddress_Zip" },
{ "mData": "CustSurvey_Location" },
{ "mData": "PolicyNo" },
{ "mData": "ProfitCenter" },
{ "mData": "FeeCompany" },
]
});
});
</script>
</head>
<body id="dt_example">
<div id="container">
<div id="links">
Server-side processing with object source <br />
</div>
<div id="demo_jui">
<table id="lplist" class="display">
<thead>
<tr>
<th>Insured Name</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>Survey Location</th>
<th>PolicyNo</th>
<th>Profit Center</th>
<th>Fee Company</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
答案 0 :(得分:8)
初始化数据表时在选项中添加defaultContent。有关详细信息
答案 1 :(得分:5)
您可以使用mRender
指定空值时的显示:
{
"mData": "FeeCompany"
'mRender': function (data, type, full) {
if (full[7] !== null) {
return full[7];
}else{
return '';
}
},
答案 2 :(得分:0)
{
"data": function(data, type, dataToSet) {
return data.CourseEducator1 ? ? " " + "<br/>" + data.CourseEducator2 ? ? ";
}
}