rks*_*rks 8 javascript datatable jquery jquery-datatables
我有一个jquery数据表,数据来自数据库,从java servlet获取.很少列有空值.因为我得到警告像
DataTables警告:table id = lplist - 第9行请求的未知参数'FeeCompany'.有关此错误的更多信息,请参阅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>
Run Code Online (Sandbox Code Playgroud)
您可以使用mRender在空值的情况下指定显示:
{
"mData": "FeeCompany"
'mRender': function (data, type, full) {
if (full[7] !== null) {
return full[7];
}else{
return '';
}
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18954 次 |
| 最近记录: |