Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
144
rated 0 times [  146] [ 2]  / answers: 1 / hits: 24529  / 10 Years ago, tue, december 16, 2014, 12:00:00

I have a jquery datatable with the data coming from database,fetched from java servlet.Few columns have null values.Because of this i am getting warning like




DataTables warning: table id=lplist - Requested unknown parameter 'FeeCompany' for row 9. For more information about this error, please see http://datatables.net/tn/4




I want those null values to be replaced by empty string.Can someone please guide how to achieve this.



My code snippet is as below



    <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>

More From » jquery

 Answers
25

Add defaultContent in the options while initializing the data table. For more details


columns.defaultContent


Example from the official documentation:


$('#example').dataTable( {
"columns": [
null,
null,
null,
{
"data": "first_name", // can be null or undefined
"defaultContent": "<i>Not set</i>"
}
]
} );

[#68475] Friday, December 12, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
skyler

Total Points: 646
Total Questions: 119
Total Answers: 96

Location: Bonaire
Member since Wed, Mar 29, 2023
1 Year ago
;