error while using fnAddData

error while using fnAddData

merihmerih Posts: 24Questions: 0Answers: 0
edited March 2012 in General
Hi,

I try to use fnAddData to add a new row in dataTable but I got error below..
"DataTable warning(table id= 'example3'): Requested unknown parameter 'systemId' from the data source for row 6734."

The problem is I have used fnAddData lots of times in my project but I didnt understand why I got error at this time.

[code]

function addMatchedRowsJS(){
var addedData = new Array();
addedData[0] = "test1";
addedData[1] = "test2";
addedData[2] = "test3";
addedData[3] = "test4";
addedData[4] = "test5";
addedData[5] = "test6";
addedData[6] = "";
addedData[7] = "";
addedData[8] = "";
addedData[9] = "test10";
alert(addedData);

$('#example3').dataTable().fnAddData(addedData);
}

[/code]

Replies

  • merihmerih Posts: 24Questions: 0Answers: 0
    DataTable;

    [code]

    var id = $("#matchTypeId").val();

    $('#example3').dataTable( {
    "bServerSide": false,
    "bProcessing": true,
    "bDeferRender": true,
    "sAjaxSource": "../servlets/MatchedListWithDraftServlet?matchTypeId="+id,
    "sServerMethod": "GET",
    "bRetrieve": true,
    "sAjaxDataProp": "",
    "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
    $(nRow).addClass('gradeA');
    },
    "fnInitComplete": function(oSettings, json) {
    resize();
    hideLoading();
    },
    "aoColumns": [

    { "mDataProp": "systemId"},
    { "sDefaultContent": "","fnRender": function(oObj) {
    var sou = oObj.aData.startOfUse;
    var eou = oObj.aData.endOfUse;
    if (sou=="" && eou=="" )
    return "";
    else
    return "";} },
    { "mDataProp": "leftEntityIdentity"},
    { "mDataProp": "leftEntityName"},
    { "mDataProp": "rightEntityIdentity"},
    { "mDataProp": "rightEntityName"},
    { "mDataProp": "dateModified"},
    { "mDataProp": "startOfUse"},
    { "mDataProp": "endOfUse"},
    { "sDefaultContent": "","fnRender": function(oObj) {
    var sId = oObj.aData.systemId;
    return "Scope";} }
    ],
    "bRetrieve": true,
    "bAutoWidth": false,
    "sDom": 'CT<"clear">lfrtip',
    "oColVis": {
    "aiExclude": [ 0,1,8 ]
    },
    "oTableTools": {
    "sSwfPath": "../resources/swf/copy_cvs_xls_pdf.swf",
    "aButtons": [
    "copy",
    {
    "sExtends": "collection",
    "sButtonText": "Save",
    "aButtons": [ "xls", "pdf", "csv" ]
    }
    ]
    },
    "aoColumnDefs": [
    { "bVisible": false, "aTargets": [ 0,6,8,9 ] },
    { "bSortable": false, "aTargets": [ 1 ] },
    { "sWidth": "3%", "aTargets": [ 1 ] },
    { "sWidth": "15%", "sType": "date-euro", "aTargets": [ 6 ] },
    { "sWidth": "15%", "sType": "date-euro", "aTargets": [ 7 ] },
    { "sWidth": "15%", "sType": "date-euro", "aTargets": [ 8 ] }
    ],
    "aaSorting": [[ 7, "desc" ]]
    });

    [/code]
  • merihmerih Posts: 24Questions: 0Answers: 0
    edited March 2012
    true way is

    [code]

    function addMatchedRowsJS(){
    $('#example3').dataTable().fnAddData([{systemId: 'A', leftEntityIdentity: 'B',leftEntityName: 'C',rightEntityIdentity: 'D',rightEntityName : 'E',dateModified: '',startOfUse: '',endOfUse: ''}]);
    }

    [/code]
This discussion has been closed.