Displaying table using AjaxSource, DataTables warning: requested unknown parameter '0' from the data
Displaying table using AjaxSource, DataTables warning: requested unknown parameter '0' from the data
kulkarni_ash
Posts: 35Questions: 8Answers: 0
I downloaded datatable and added it to my SpringMVC project, and i created following in my jsp and java script and i get the following error
[code]datatables warning request unknow parameter '0' from the data source for row 0[/code]
[code]
$(document).ready(function() {
$('#airports').dataTable({
"bSort": false,
"sPaginationType": "full_numbers" ,
"bProcessing": true,
"sAjaxSource": 'displayAirportAjax.spring'
}
);
} );
Select
Code
Name
City
State
Country
Type
Is Tauck Provided
Is City Default
[/code]
The JSON array i return is as below
[code]
aaData= [{"AIRPORTCD":"","AIRPORTID":0,"AIRPORTNAME":"","CITYCD":"","CITYCOUNTRYCD":"","CITYNAME":"","COUNTRYCD":"","COUNTRYNAME":"","EFFECTIVEDATE":null,"ISCITYDEFAULT":"","ISOA2":"","ISTAUCKPROVIDED":"","RETIREDATE":null,"STATECD":"","STATENAME":"","TRANSPORTATIONTYPECD":""}]
[/code]
[code]datatables warning request unknow parameter '0' from the data source for row 0[/code]
[code]
$(document).ready(function() {
$('#airports').dataTable({
"bSort": false,
"sPaginationType": "full_numbers" ,
"bProcessing": true,
"sAjaxSource": 'displayAirportAjax.spring'
}
);
} );
Select
Code
Name
City
State
Country
Type
Is Tauck Provided
Is City Default
[/code]
The JSON array i return is as below
[code]
aaData= [{"AIRPORTCD":"","AIRPORTID":0,"AIRPORTNAME":"","CITYCD":"","CITYCOUNTRYCD":"","CITYNAME":"","COUNTRYCD":"","COUNTRYNAME":"","EFFECTIVEDATE":null,"ISCITYDEFAULT":"","ISOA2":"","ISTAUCKPROVIDED":"","RETIREDATE":null,"STATECD":"","STATENAME":"","TRANSPORTATIONTYPECD":""}]
[/code]
This discussion has been closed.
Replies
Allan
Thanks i added the following code as below
[code]
"aoColumns": [
{ "mDataProp": "airportcd" }
]
[/code] and it worked great,
Once more question, i want to add a check box for first columns, can you point towards some example to do so
1. Simply include the checkbox HTML in your JSON return and use that for the column
2. Use fnRender for that column to create the needed HTML
3. Use sDefaultContent to create the needed HTML (although with this method you can't set a unique ID/Name for the checkbox, which you would presumably want).
Allan
Thanks for the information, i converted by definition as below and it is working fine, I have one more question
My resultset returns about 3500 rows, and so rendering of table takes little time, is there some parameter which can speed up rendering of table? this is a big issue since users get frustrated when application loads slowly, i really dont want to implement some server side code to load 500 at a time or some thing, is there any parameter in Datatables to help
My new code in java script is as below, and works very well expect for the speed
[code]
$(document).ready(function() {
$('#airports').dataTable({
"bSort": false,
"sPaginationType": "full_numbers" ,
"bProcessing": true,
"sAjaxSource": 'displayAirportAjax.spring',
"aoColumns": [
{
"fnRender": function ( oObj ) {
return '';
}
}
,
{
"fnRender": function ( oObj ) {
var text = "" + oObj.aData.airportcd + "";
return text;
}
},
{ "mDataProp": "airportname" },
{ "mDataProp": "cityname" },
{ "mDataProp": "statename" },
{ "mDataProp": "countryname" },
{ "mDataProp": "transportationtypecd" },
{ "mDataProp": "istauckprovided" },
{ "mDataProp": "iscitydefault" }
]
}
);
} );
[/code]
Allan
Allan