I have a DataTables setup as follows.
var pageData = [
{
"id":"2",
"slug":"about\/history",
"title":"History",
"last_updated":"2013-04-21 09:50:41"
},
{
"id":"3",
"slug":"about",
"title":"About",
"last_updated":"2013-04-21 10:42:22"
}
];
$(function () {
$("#pageList").dataTable({
"aaData" : pageData,
"aoColumns" : [
{
"sTitle" : "slug"
},
{
"sTitle" : "title"
},
{
"sTitle" : "last_updated"
},
{
"sTitle" : "id"
}
]
});
});
Now, when I run this, I get the following error alert
DataTables warning (table id = 'pageList'):
Requested unknown parameter '0' from the data source for row 0
And I assume it is because datatables using indexes instead of column names to access data from pageData
. I thought sTitle
will do the work, but it doesn't. Now, I can't find an appropriate option to specify column names to datatable other than sName
which is used only when sending data to server.
I feel that the solution will be a simple one which I overlooked. Well, what am I missing here?