How to fix 'requested unknown parameter '0' for row 0'
How to fix 'requested unknown parameter '0' for row 0'
abhilashamishra17
Posts: 13Questions: 3Answers: 0
I'm returning a list of objects from my Controller as JsonResult.
Structure of my object-
public class NumModel
{
int Number { get; set; }
string Status { get; set; }
public NumModel(int number, string status)
{
this.Number = number;
this.Status = status;
}
}
Getting 'requested unknown parameter '0' for row 0' when trying to populate DataTable.
function populatefizzbuzzlist(data) {
$("#results tbody").html("");
debugger;
var otable = $("#results").dataTable({
"aaData": data,
"aaSorting" : [[0, "asc" ]],
"bJQueryUI": true,
"bFilter": true,
"bStateSave": true,
"bDestroy": true,
"bDeferRender": true,
"bProcessing": true,
"bPaginate": true,
"bLengthChange": false,
"iDisplayLength": 20,
"bAutoWidth": true,
"sScrollY": "500px",
"aoColumns": [
{
"bSortable": true,
"sClass": "left",
fnrender: function (obj) {
return obj.aData.Number;
}
},
{
"bSortable": true, "sClass": "left", fnRender: function (obj) {
var cellValue = obj.aData.Status;
if (cellValue == "fizz") {
return "<span class=\"greenText\">" + cellValue + "</span>";
}
else if (cellValue == "buzz") {
return "<span class=\"blueText\">" + cellValue + "</span>";
}
else {
return cellValue;
}
return obj.aData.Status;
}
}
]
});
$("#results").css('width', "100%");
This discussion has been closed.
Answers
Pre the forum rules, please link to a test case or show a debugger trace.
Allan
HTML1300: Navigation occurred.
File: localhost:50915
SCRIPT5007: Unable to get property 'length' of undefined or null reference
File: jquery.dataTables.min.js, Line: 21, Column: 52
HTML1513: Extra "<html>" tag found. Only one "<html>" tag should exist per document.
File: localhost:50915, Line: 5, Column: 1
HTML1503: Unexpected start tag.
File: localhost:50915, Line: 6, Column: 1
HTML1512: Unmatched end tag.
File: localhost:50915, Line: 10, Column: 1
HTML1514: Extra "<body>" tag found. Only one "<body>" tag should exist per document.
File: localhost:50915, Line: 11, Column: 1
HTML1506: Unexpected token.
File: localhost:50915, Line: 28, Column: 5
Bookmarklet code - igotoc
I would suggest correct the HTML validation errors first. DataTables assumes that valid HTML is being used.
Allan
Fixed HTML errors. new bookmarklet code -ohizuk
Exception was thrown at line 5163, column 8 in http://localhost:50915/Scripts/jquery-1.7.2.js
0x800a139e - JavaScript runtime error: SyntaxError
Unhandled exception at line 21, column 52 in http://localhost:50915/Scripts/DataTables/jquery.dataTables.min.js
0x800a138f - JavaScript runtime error: Unable to get property 'length' of undefined or null reference
The program '[1080] iisexpress.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).
The program '[8852] iexplore.exe' has exited with code -1 (0xffffffff).
One finding...its able to receive a simple integer list. Its only when an object list is returned from C# it fails to bind correctly.AM I missing any references to recieve JSON?
You need to use
columns.data
to tell DataTables what data property from each row object to use. Example.Allan
No luck.
I'm not getting any errors now. But nothing gets displayed on the UI.
Posting my definitions again.
Ok...By putting a debugger I can see that it loaded data, but as soon as the method completes, everything gets cleared off the UI.
Please help this is urgent....
Please link to a test case showing the issue, so we can help to resolve your urgent problem.
Allan
Not sure how to write test cases for datatable load
Use JSFiddle or https://live.datatables.net if you can't give us a link to your page.
Allan