Datatables warning - Unknown Parameter
Datatables warning - Unknown Parameter
Nfernus
Posts: 3Questions: 0Answers: 0
http://debug.datatables.net/eyiteg
From what I can tell in the Debugger, it sees all the data in my JSON, and I know the JSON is formatted correctly. For some reason, since I moved this out to a separate function which defines the columns it is inserting a false row "0" which of course is always null. Any thoughts?
[code]
function leaderboard(){
// Production End Point
// var jsonsource = sessvars.lbendpoint;
var jsonsource = 'js/json/playerResultsLB.json'
// Initialize Datatable
var oTable = $('#leaderboard').dataTable({
"sDom": '<"search"f>rt<"info"ip>',//<"pagination"p>',
"sPaginationType": "full_numbers",
"bLengthChange": false,
"iDisplayLength": 20,
"bProcessing": true,
"sAjaxSource": jsonsource,
"sAjaxDataProp": "leaderboardResults",
"aoColumns": columns(),
}); // End Datatable
}
function columns(){
var rows ='{ "sTitle" : "Position", "mDataProp": "curPosition" },';
rows+='{ "sTitle" : "Player Name", "mDataProp": "playerName" },';
if(sessvars.lbratio==="WvL"){
rows+='{ "sTitle" : "Ratio", "mDataProp": "ratio" },';
rows+='{ "sTitle" : "Wins", "mDataProp": "wins" },';
rows+='{ "sTitle" : "Losses", "mDataProp": "losses" },';
};
return rows;
}
[/code]
From what I can tell in the Debugger, it sees all the data in my JSON, and I know the JSON is formatted correctly. For some reason, since I moved this out to a separate function which defines the columns it is inserting a false row "0" which of course is always null. Any thoughts?
[code]
function leaderboard(){
// Production End Point
// var jsonsource = sessvars.lbendpoint;
var jsonsource = 'js/json/playerResultsLB.json'
// Initialize Datatable
var oTable = $('#leaderboard').dataTable({
"sDom": '<"search"f>rt<"info"ip>',//<"pagination"p>',
"sPaginationType": "full_numbers",
"bLengthChange": false,
"iDisplayLength": 20,
"bProcessing": true,
"sAjaxSource": jsonsource,
"sAjaxDataProp": "leaderboardResults",
"aoColumns": columns(),
}); // End Datatable
}
function columns(){
var rows ='{ "sTitle" : "Position", "mDataProp": "curPosition" },';
rows+='{ "sTitle" : "Player Name", "mDataProp": "playerName" },';
if(sessvars.lbratio==="WvL"){
rows+='{ "sTitle" : "Ratio", "mDataProp": "ratio" },';
rows+='{ "sTitle" : "Wins", "mDataProp": "wins" },';
rows+='{ "sTitle" : "Losses", "mDataProp": "losses" },';
};
return rows;
}
[/code]
This discussion has been closed.
Replies
The reason for that is your columns() function is returning a string, not a Javascript object as required. In fact it needs to be an array of objects, not a string.
Allan