aoColumns concerns
aoColumns concerns
jackmapa
Posts: 4Questions: 0Answers: 0
Im getting the error below when i get data from the server
DataTables warning (table id = 'example'): Added data (size undefined) does not match known number of columns (19),
do i need to return an exact number of columns in the aaData as to what i have in the aoColumns ?, below is the sample response from the server, i need most of the data so that i can put it in a hidden fields.
"aaData":[{"products":null,"id":3461.0,"description":"CONFETTI BOWS","category":null,"subCommodity":null,"commodity":null,"itemClass":null,"dcId":null,"caseUpc":1.81001331E9,"subDepartment":null,"active":false,"estimatedCost":null,"estimatedRetail":null,"maximumOrderQuantity":null,"message":null,"shelfLocation":"O","attachments":null,"configuration":null,"surrogateItem":null,"historyStartDate":null,"historyEndDate":null,"minimumOrderQuantity":null,"costOverridden":false,"retailOverridden":false,"shipmentNotes":false,"shipmentMethodType":null,"regularUnitCost":null,"regularUnitRetail":null,"pack":null,"frontPageAd":false,"availableQuantity":null,"onHold":false,"dataCollLvlAdj":null,"stored":false,"retailSize":null},
DataTables warning (table id = 'example'): Added data (size undefined) does not match known number of columns (19),
do i need to return an exact number of columns in the aaData as to what i have in the aoColumns ?, below is the sample response from the server, i need most of the data so that i can put it in a hidden fields.
"aaData":[{"products":null,"id":3461.0,"description":"CONFETTI BOWS","category":null,"subCommodity":null,"commodity":null,"itemClass":null,"dcId":null,"caseUpc":1.81001331E9,"subDepartment":null,"active":false,"estimatedCost":null,"estimatedRetail":null,"maximumOrderQuantity":null,"message":null,"shelfLocation":"O","attachments":null,"configuration":null,"surrogateItem":null,"historyStartDate":null,"historyEndDate":null,"minimumOrderQuantity":null,"costOverridden":false,"retailOverridden":false,"shipmentNotes":false,"shipmentMethodType":null,"regularUnitCost":null,"regularUnitRetail":null,"pack":null,"frontPageAd":false,"availableQuantity":null,"onHold":false,"dataCollLvlAdj":null,"stored":false,"retailSize":null},
This discussion has been closed.
Replies
If you don't specify mDataProp (the data properties to put into each column) DataTables assumes you are going to return an array of arrays with the exact number of columns in the array to match the number of columns in the table.
I have tried that but im still getting the sample prob, I just have it all "mDataProp": "id" to test if i can display it.. see my sample code below.
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"aoColumns": [
{ "asSorting": false, "mDataProp": "id" },
{ "asSorting": [ "desc","asc" ], "mDataProp": "id" },
{ "asSorting": [ "desc", "asc"], "mDataProp": "id" },
{ "asSorting": [ "desc", "asc" ], "mDataProp": "id" },
{ "asSorting": false, "mDataProp": "id"},
{ "asSorting": false, "mDataProp": "id"},
{ "asSorting": false, "mDataProp": "id"},
{ "asSorting": false, "mDataProp": "id"},
{ "asSorting": false, "mDataProp": "id"},
{ "asSorting": false,"mDataProp": "id"},
{ "asSorting": false,"mDataProp": "id"},
{ "asSorting": false,"mDataProp": "id"},
{ "asSorting": false,"mDataProp": "id"},
{ "asSorting": false,"mDataProp": "id"},
{ "asSorting": false,"mDataProp": "id"},
{ "asSorting": false,"mDataProp": "id"},
{ "asSorting": false,"mDataProp": "id"},
{ "asSorting": false,"mDataProp": "id"},
{ "asSorting": false,"mDataProp": "id"},
],
"aLengthMenu":[50,100,250,500],
"sAjaxSource": "${pageContext.request.contextPath}/bdm/itemSelection/eventItemList.htm",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
.....
},
} );
Allan
I have also tried the codes below but still having the same issue.
$('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "${pageContext.request.contextPath}/bdm/itemSelection/eventItemListDataTables.htm",
"aoColumns": [
{ "mDataProp": "id" },
{ "mDataProp": "description" },
{ "mDataProp": "id" },
{ "mDataProp": "description" },
{ "mDataProp": "id" },
{ "mDataProp": "description" },
{ "mDataProp": "id" },
{ "mDataProp": "description" },
{ "mDataProp": "id" },
{ "mDataProp": "description" },
{ "mDataProp": "id" },
{ "mDataProp": "description" },
{ "mDataProp": "id" },
{ "mDataProp": "description" },
{ "mDataProp": "id" },
{ "mDataProp": "description" },
{ "mDataProp": "id" },
{ "mDataProp": "description" },
{ "mDataProp": "id" }
]
} );
Allan
* File: jquery.dataTables.js
* Version: 1.8.2
Sorry Im working in my local machine right now.
I tried getting the data using the code below and I was able to get the Json Data
[code]
$.ajax({
type: "GET",
url: "${pageContext.request.contextPath}/bdm/itemSelection/eventItemList.htm",
dataType: "json",
success: function(json) {
oTable.fnClearTable();
$.each(json, function(index, assignedItem) {
oTable.fnAddData([
"",
assignedItem.id,
assignedItem.caseUpc,
assignedItem.description,
"",
"",
"",
"",
(assignedItem.configuration==null)?"":assignedItem.configuration.id,
"",
"",
"",
"",
"",
"",
"",
"",
"",
"