aoColumns concerns

aoColumns concerns

jackmapajackmapa Posts: 4Questions: 0Answers: 0
edited November 2011 in DataTables 1.8
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},

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    If you specify mDataProp (which you'd need if using the array-of-object form of aaData that you have) the number of columns wouldn't have to match.

    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.
  • jackmapajackmapa Posts: 4Questions: 0Answers: 0
    edited November 2011
    fbas Thanks for the reply.

    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
    } );

    .....



    },
    } );
  • allanallan Posts: 63,277Questions: 1Answers: 10,424 Site admin
    Two issues I can see with the code above - firstly you have a trailing comma in aoColumns. You want to remove that :-). Secondly, asSorting cannot be false - if you want to disallow sorting on a column use bSortable .

    Allan
  • jackmapajackmapa Posts: 4Questions: 0Answers: 0
    Hi Allan, appreciate your response.

    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" }
    ]
    } );
  • allanallan Posts: 63,277Questions: 1Answers: 10,424 Site admin
    Are you using DataTables 1.8? Can you post a link to your page please?

    Allan
  • jackmapajackmapa Posts: 4Questions: 0Answers: 0
    edited November 2011
    /*
    * 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,
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "
This discussion has been closed.