Load datatable with JSON data gives an error Requested unknown parameter '0' from the data source f
Load datatable with JSON data gives an error Requested unknown parameter '0' from the data source f
ashvini
Posts: 2Questions: 0Answers: 0
I have been trying to load json data into datatable but somehow it fails and displays " Requested unknown parameter '0' from the data source for row 0" error and no data is populated in the table.
I referred all possible sources available online but i am still not able to get around it .
I am a complete newbie in jquery programming and using handlebar for templating.
[code]
(function( $ ){
$.fn.managecontractsview = function() {
return this.each(function() {
objManageContract = $(this)
//use jQuery ".live" function to bind to events from controller and other views
function loadJsonData(){
commandFactory.create({'type': 'getContracts',
'params': {},
'successhandler': function(reply){
//trigger event to notify any views listening for contracts
$.event.trigger('loadContractList',reply.response );
},
'errorhandler': function(reply) {
alert('Error retrieving Contracts, error status of: ' + reply.status.text);
$.event.trigger('loadContractListError', 'Error retrieving contract list, error status of: ' + reply.status.text);
}}).execute();
}
objManageContract.live(
{
loadSearchContract: function(event, contract) {
templ = Handlebars.templates["manageContracts"];
objManageContract.html(templ(contract));
// load list on search input
$("#contract-search-input").live('keyup',function(event){
if(event.keyCode == 13){
alert("in click of search");
loadJsonData();
}
});
}
loadContractList: function(event, contract){
var oTable = $('#contract-list').dataTable({
"bJQueryUI": true,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false,
"bRetrieve": true,
"aaData":[contract],
/* "aaData": [[ "Aetna","12345"],
["BCBS Society", "78686"],
[ "Wallmark", "989083"/01/2012" ]],*/
"aoColumns": [
{ "sTitle": "name" },
{ "sTitle": "alias" }
]
});
[/code]
If I use a static data array (the commented one), it works fine.
So it makes me think the way i m getting the json data is errorneous.
I will appreciate if i can get any help in this matter.I have been struggling on this for past couple of days.
I even tried converting the json object into an javascript array , but even that did not work.
Thank you for helping.
I referred all possible sources available online but i am still not able to get around it .
I am a complete newbie in jquery programming and using handlebar for templating.
[code]
(function( $ ){
$.fn.managecontractsview = function() {
return this.each(function() {
objManageContract = $(this)
//use jQuery ".live" function to bind to events from controller and other views
function loadJsonData(){
commandFactory.create({'type': 'getContracts',
'params': {},
'successhandler': function(reply){
//trigger event to notify any views listening for contracts
$.event.trigger('loadContractList',reply.response );
},
'errorhandler': function(reply) {
alert('Error retrieving Contracts, error status of: ' + reply.status.text);
$.event.trigger('loadContractListError', 'Error retrieving contract list, error status of: ' + reply.status.text);
}}).execute();
}
objManageContract.live(
{
loadSearchContract: function(event, contract) {
templ = Handlebars.templates["manageContracts"];
objManageContract.html(templ(contract));
// load list on search input
$("#contract-search-input").live('keyup',function(event){
if(event.keyCode == 13){
alert("in click of search");
loadJsonData();
}
});
}
loadContractList: function(event, contract){
var oTable = $('#contract-list').dataTable({
"bJQueryUI": true,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false,
"bRetrieve": true,
"aaData":[contract],
/* "aaData": [[ "Aetna","12345"],
["BCBS Society", "78686"],
[ "Wallmark", "989083"/01/2012" ]],*/
"aoColumns": [
{ "sTitle": "name" },
{ "sTitle": "alias" }
]
});
[/code]
If I use a static data array (the commented one), it works fine.
So it makes me think the way i m getting the json data is errorneous.
I will appreciate if i can get any help in this matter.I have been struggling on this for past couple of days.
I even tried converting the json object into an javascript array , but even that did not work.
Thank you for helping.
This discussion has been closed.
Replies
Can you give us a debugger trace please?
Allan
[code]
"aoColumns" : [
{ "sTitle" : "Formal Name", "mData" : "column_key_name"},
{ "sTitle" : "Formal Title", "mData" : "column_key_title"},
[/code]