Help Needed with DataTable JSon

Help Needed with DataTable JSon

deandalbydeandalby Posts: 1Questions: 0Answers: 0
edited March 2013 in DataTables 1.9
Hi All, could someone help me with the following issue. when the data table loads I get the following error. Below is the Html, Javascript and json data source.

---------------------------
Message from webpage
---------------------------
DataTables warning (table id = 'ProjectItemsDataTable'): Requested unknown parameter '0' from the data source for row 0
---------------------------
OK
---------------------------

The HTML is





Name


Type


Owner


Closed On


Due Date









The datatable set up is as follows

$('#ProjectItemsDataTable').dataTable({
"bServerSide": true,
"sAjaxSource": "ProjectItem/ProjectItemsDataTableAjaxHandler",
"bProcessing": true,
"aoColumns": [
{"sName": "Name" },
{ "sName": "Type" },
{ "sName": "Owner" },
{ "sName": "ClosedOn" },
{ "sName": "DueDate" }
]
});




The JSon posted back to the datatable is
{
"sEcho":"1",
"iTotalRecords":14,
"iTotalDisplayRecords":14,
"aaData":[
{
"Name":"t",
"Type":"t",
"Owner":"qq",
"ClosedOn":"\/Date(1340985600000)\/",
"DueDate":"\/Date(1340985600000)\/"
},
{
"Name":"21",
"Type":"Bug",
"Owner":"tes",
"ClosedOn":"\/Date(1362499200000)\/",
"DueDate":"\/Date(1384444800000)\/"
},
{
"Name":"tt",
"Type":"Bug",
"Owner":"tt",
"ClosedOn":"\/Date(1364572800000)\/",
"DueDate":"\/Date(1364659200000)\/"
},
{
"Name":"p1",
"Type":"p1",
"Owner":"p1",
"ClosedOn":null,
"DueDate":null
},
{
"Name":"aaa",
"Type":"aaa",
"Owner":"aaa",
"ClosedOn":null,
"DueDate":null
},
{
"Name":"qq",
"Type":"qq",
"Owner":"qq",
"ClosedOn":null,
"DueDate":null
},
{
"Name":"qq",
"Type":"qq",
"Owner":"qq",
"ClosedOn":null,
"DueDate":null
},
{
"Name":"qq",
"Type":"qq",
"Owner":"qq",
"ClosedOn":null,
"DueDate":null
},
{
"Name":"qq",
"Type":"qq",
"Owner":"qq",
"ClosedOn":null,
"DueDate":null
},
{
"Name":"dddddd",
"Type":"dddddd",
"Owner":"dddddd",
"ClosedOn":null,
"DueDate":null
},
{
"Name":"aa",
"Type":"aa",
"Owner":"aa",
"ClosedOn":null,
"DueDate":null
},
{
"Name":"aa",
"Type":"aa",
"Owner":"qqqqqqq",
"ClosedOn":null,
"DueDate":null
},
{
"Name":"qq",
"Type":"Action",
"Owner":"qqqqqqq",
"ClosedOn":null,
"DueDate":null
},
{
"Name":"1234",
"Type":"Bug",
"Owner":"qqwfdfddd",
"ClosedOn":null,
"DueDate":null
}
]
}

Replies

  • allanallan Posts: 63,389Questions: 1Answers: 10,449 Site admin
    You want mData rather than sName . Also since you have null values you'll need to use sDefaultContent to tell DataTables how you want it to display those null values.

    Allan
This discussion has been closed.