I am working on datable that populate the data from server side, issue i am facing is that it always give a alert box that shows
DataTables warning: table id=firmtable - Requested unknown parameter '1' for row 0. For more information about this error, please see http://datatables.net/tn/4 i am unable to trace where this issue might be
my json
{
"sEcho":"3",
"iTotalRecords":10,
"iTotalDisplayRecords":10,
"aaData":
"[
{\"LogId\":\"108\",
\"tableName \":\"game\",
\"columnName\":\"Status\",
\"oldValue\":\"0\",
\"newValue\":\"1\",
\"changeTypeText\":\"Update \",
\"changedByName\":\"abc\"}
]"
}
this is how i have worked it on server side
Iterator<LogInfo> i = logList.iterator();
int row = 0;
JsonObject returnObj = new JsonObject();
JsonArray dataArray = new JsonArray();
while (i.hasNext()) {
LogInfo logInfo = (LogInfo) i.next();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("logId", logInfo.getLogId());
jsonObject.addProperty("tableName", logInfo.getTableName());
jsonObject.addProperty("columnName", logInfo.getColumnName());
jsonObject.addProperty("oldValue", logInfo.getOldValue());
jsonObject.addProperty("newValue", logInfo.getNewValue());
jsonObject.addProperty("changeTypeText", logInfo.getChangeTypeText());
jsonObject.addProperty("changedByName", logInfo.getChangedByName());
row++;
dataArray.add(jsonObject.getAsJsonObject());
}
returnObj.addProperty("sEcho", "3");
returnObj.addProperty("iTotalRecords", row);
returnObj.addProperty("iTotalDisplayRecords", row);
returnObj.addProperty("aaData", dataArray.toString());
PrintWriter out = response.getWriter();
Gson gson = null;
GsonBuilder builder = new GsonBuilder();
builder.setDateFormat(JarolConstants.AJAX_DATE_FORMAT);
gson = builder.create();
String resultStr = gson.toJson(returnObj);
out.print(resultStr);
out.close();
whats happening on the client side it that mytable is not getting populated html code
script
$(document).ready(function() {
$('#firmtable').dataTable({
"bProcessing" : true,
bServerSide : true,
sAjaxSource : "./log!list.action",
sServerMethod : "POST"
});
}); </script>
<table id="firmtable">
<thead>
<tr class="detail">
<th><s:property value="getText('auditLog.jsp.transactionId')" /></th>
<th><s:property value="getText('auditLog.jsp.tableName')" /></th>
<th><s:property value="getText('auditLog.jsp.columnName')" /></th>
<th><s:property value="getText('auditLog.jsp.oldValue')" /></th>
<th><s:property value="getText('auditLog.jsp.newValue')" /></th>
<th><s:property value="getText('auditLog.jsp.changeTypeId')" /></th>
<th><s:property value="getText('auditLog.jsp.changeBy')" /></th>
<th><s:property value="getText('auditLog.jsp.changeOn')" /></th>
<th class="edit"><s:property value="getText('global.action')" /></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
EDIT i have also tried sEcho value setting it to
returnObj.addProperty("sEcho", Integer.parseInt(request.getParameter("sEcho")));
but no result, same issue i am getting
what result i get is the table first column gets populated with the aaData content like this
[ { L o g I d 1 0 8 i.e. single letter in first column