[SOLVED] Requested unknown parameter '0' from the data source for row 0
[SOLVED] Requested unknown parameter '0' from the data source for row 0
I'm getting "Requested unknown parameter '0' from the data source for row 0" and it's driving me batty. I've read all of the forum entries and either I just missed it or it wasn't posted.
The debug report (which is *incredible* by the way):
http://debug.datatables.net/iyaruy
Browser is Firefox 12.0 on WinXP SP3.
It appears that DataTables is inserting extra columns. (Is it?) See the 0, 1, 2 columns?
{
"Backup status": "Success",
"Monitoring status": "Success",
"Hostname": "usvxapunixp01",
"0": null,
"1": null,
"2": null
}
I say that because this is what the JSON looks like:
{"iTotalRecords": 1, "aaData": [{"Backup status": "Success", "Monitoring status": "Success", "Hostname": "examplehost"}], "sEcho": 0, "iTotalDisplayRecords": 10}
And the HTML:
Hostname
Monitoring status
Backup status
Please assist. Thanks!! Great product.
The debug report (which is *incredible* by the way):
http://debug.datatables.net/iyaruy
Browser is Firefox 12.0 on WinXP SP3.
It appears that DataTables is inserting extra columns. (Is it?) See the 0, 1, 2 columns?
{
"Backup status": "Success",
"Monitoring status": "Success",
"Hostname": "usvxapunixp01",
"0": null,
"1": null,
"2": null
}
I say that because this is what the JSON looks like:
{"iTotalRecords": 1, "aaData": [{"Backup status": "Success", "Monitoring status": "Success", "Hostname": "examplehost"}], "sEcho": 0, "iTotalDisplayRecords": 10}
And the HTML:
Hostname
Monitoring status
Backup status
Please assist. Thanks!! Great product.
This discussion has been closed.
Replies
So the issue here is that you need to tell DataTables what parameter from your JSON you want to assign to each column. At the moment you have "Monitoring status" etc, but DataTables can have no idea that you want that attached to a given column (yes the names match, but that's very unusual :-) ).
The way to do it is to use mDataProp - fully described in this blog post: http://datatables.net/blog/Extended_data_source_options_with_DataTables
Allan
Good to hear you got it working.
Allan
I followed the post and links to the use of mDataProp. I've tried reducing input params, using more, alternative values - the works. I'd appreciate a few minutes of your time to look over my usage and tell me where I've gone wrong.
Thanks in advance-
USAGE --
$(document).ready(function() {
$('#tbl_vendors').hide();
var oTable = $('#tbl_vendors').dataTable( {
"bProcessing": true,
"bServerSide": true,
"iDisplayStart": 0,
"iColumns": 1,
"sAjaxDataProp": "aaData",
"sAjaxSource": "fws_json_dt.pl?rc=get_vendors_dt",
"aoColumns " : [ { "mDataProp": "vname" } ],
"oLanguage": {
"sSearch": "Vendor Name: ",
"sZeroRecords": "No records matched your criteria"
}
} );
/* Draw table when contents of search textbox changes */
$('div.dataTables_filter input').keyup( function () {
var oSettings = oTable.fnSettings();
if ($('.dataTables_filter input').val().length == 0) {
oSettings._iDisplayLength = 1;
$('#tbl_vendors_paginate')[0].style.display = "none";
}
else {
oSettings._iDisplayLength = 10;
$('#tbl_vendors_paginate')[0].style.display = "block";
}
oTable.fnDraw();
} );
// These objects are hidden by default, allowing query to bring back results before displaying table
$('#div_vendors').show();
$('#tbl_vendors').show();
// Set focus on filter textbox
$('.dataTables_filter input:text').focus();
}
JSON source --
{ "sEcho": 4, "iTotalRecords": 57, "iTotalDisplayRecords": 57, "aaData" : [ {
"vname":"SMITH, JOHN"
}
] }
It would also be worth upgrading to the latest release of DataTables.
Allan
Allan
I modified the JSON set to include two rows (wanted to see an odd/even row). The error went away, as did the row data - "0": null. However, table row values for both display the text "undefined", rather than the JSON value.
Vendor Name
BTW - we have other forms running datatables, though this is the first to use server-side processing. Users are ecstatic about the product.
fnRender is depreciated in 1.9.4 and I'd strongly recommend you use mRender (and mData rather than mDataProp).
Also, yes your HTML looks fine.
> Users are ecstatic about the product.
Excellent :-)
Allan