"Requested unknown parameter" when using mDataProp (incl. debug data)
"Requested unknown parameter" when using mDataProp (incl. debug data)
MikeZuber
Posts: 3Questions: 0Answers: 0
Allan,
Hey there. I was hoping you could help me with an issue I'm seeing with DataTables v1.9.0 + .NET 3.5 ScriptServices. I keep getting the following error when my table is first being rendered:
[quote]DataTables warning (table id = 'tblRequests'): Requested unknown parameter 'Id' from the data source for row 0[/quote]
I used your debugger bookmarklet and the code for the debug data is: uwenar
The thing that really bothers me is that once you click "OK" to clear the error, the table renders fine. (There are cosmetic issues, but they are unrelated.) I'm interpreting this to mean the JSON data being returned by my server is formatted correctly (albeit as an array of Objects, not a 2D array).
My issue is similar to this post:
http://datatables.net/forums/discussion/9030/using-fnrender-with-ajax-source-datatable/p1
I can make the error go away by specifying a value for "sDefaultContent" for each node in my aoColumnDefs array. Unlike that previous post, though, I have to specify sDefaultContent for *every* node, or else I'll still get the error. (The only change being that the error will reference the first node that does not have a sDefaultContent specified.) This workaround seems rather clunky and I was hoping you could recommend a better one.
Here is the JSON response my server generates:
{"d":{"sEcho":"1","iTotalRecords":2,"iTotalDisplayRecords":2,"aaData":[{"__type":"ELB.CIA.Model.ImpactReport","Id":124,"Description":"test","SubmittedOn":"\/Date(1332520862000)\/","SubmittedBy":"PERSON1","CompletedOn":null,"SourceSystem":0,"SourceId":0,"Status":0,"ViewOnlyInd":false},{"__type":"ELB.CIA.Model.ImpactReport","Id":120,"Description":"fake1","SubmittedOn":"\/Date(1332434462000)\/","SubmittedBy":"PERSON2","CompletedOn":null,"SourceSystem":0,"SourceId":0,"Status":2,"ViewOnlyInd":false}]}}
FYI: the "d" wrapper generated by .NET is dealt with by a converter plugged into $.ajaxSetup(),
Thanks for your time.
-Mike
Hey there. I was hoping you could help me with an issue I'm seeing with DataTables v1.9.0 + .NET 3.5 ScriptServices. I keep getting the following error when my table is first being rendered:
[quote]DataTables warning (table id = 'tblRequests'): Requested unknown parameter 'Id' from the data source for row 0[/quote]
I used your debugger bookmarklet and the code for the debug data is: uwenar
The thing that really bothers me is that once you click "OK" to clear the error, the table renders fine. (There are cosmetic issues, but they are unrelated.) I'm interpreting this to mean the JSON data being returned by my server is formatted correctly (albeit as an array of Objects, not a 2D array).
My issue is similar to this post:
http://datatables.net/forums/discussion/9030/using-fnrender-with-ajax-source-datatable/p1
I can make the error go away by specifying a value for "sDefaultContent" for each node in my aoColumnDefs array. Unlike that previous post, though, I have to specify sDefaultContent for *every* node, or else I'll still get the error. (The only change being that the error will reference the first node that does not have a sDefaultContent specified.) This workaround seems rather clunky and I was hoping you could recommend a better one.
Here is the JSON response my server generates:
{"d":{"sEcho":"1","iTotalRecords":2,"iTotalDisplayRecords":2,"aaData":[{"__type":"ELB.CIA.Model.ImpactReport","Id":124,"Description":"test","SubmittedOn":"\/Date(1332520862000)\/","SubmittedBy":"PERSON1","CompletedOn":null,"SourceSystem":0,"SourceId":0,"Status":0,"ViewOnlyInd":false},{"__type":"ELB.CIA.Model.ImpactReport","Id":120,"Description":"fake1","SubmittedOn":"\/Date(1332434462000)\/","SubmittedBy":"PERSON2","CompletedOn":null,"SourceSystem":0,"SourceId":0,"Status":2,"ViewOnlyInd":false}]}}
FYI: the "d" wrapper generated by .NET is dealt with by a converter plugged into $.ajaxSetup(),
Thanks for your time.
-Mike
This discussion has been closed.
Replies
Thanks for the debug trace! Generally your initialisation looks fine, but why are you passing in an array of nulls for aaData? It looks like you don't need to pass anything in at all for aaData - I'd just remove that and use the Ajax source as your data source.
Allan
Thanks for responding. Given that there's a workaround (simply provide an empty string for sDefaultContent for every element in aoColumnDefs ), this clearly isn't a critical issue. It's a bizarre one, though. Were you able to replicate this issue? Or am I going crazy?
As for aaData, I copied the code above from another project as a starting point and didn't think to get rid of it. Thanks for pointing out that I can remove it.
-Mike
Allan
Me also experiencing same issue the similar issue. In my MYSQL database table named browsers id is the primary field. But when the script runs it shows warning ."DataTables warning (table id = 'tblRequests'): Requested unknown parameter 'Id' from the data source for row 0" On closing the same table gives data except id.
Allan
[code] // DataTables init
$('#example').dataTable( {
"sDom": "Tfrtip",
"sAjaxSource": "php/browsers.php",
"aoColumns": [
{ "mDataProp": "id" }, /////see the only change i made//
{ "mDataProp": "browser" },
{ "mDataProp": "engine" },
{ "mDataProp": "platform" },
{ "mDataProp": "grade", "sClass": "center" },
{
"mDataProp": null,
"sClass": "center",
"sDefaultContent": 'Edit / Delete'
},
{
"mDataProp": null,
"sClass": "center",
"sDefaultContent": 'Brows'
}
]
} );[/code]
Fair enough. Did you also change the server-side script to return an 'id' property in the JSON source? There isn't one there by default, so if you didn't add one in (which is sounds like you haven't since this was the only change you made), then DataTables is quite rightly saying that there is no 'id' property.
Allan