the infamous Requested unknown parameter '0' from the data source for row error

the infamous Requested unknown parameter '0' from the data source for row error

awmitchellawmitchell Posts: 3Questions: 0Answers: 0
edited September 2012 in Editor
hey all. i would love to use the debugger, but the way my project is constructed, the debugger doesn't work properly. so, i'll be as descriptive as i can!

when i create a new row, i get this error returned:

DataTables warning (table id = 'is_database'): Requested unknown parameter '0' from the data source for row 28

i can tell you that my columns match up. i have 3 columns and 3 fields. the error gets thrown on line 2677 of the unminified dataTables.editor.js file.

this one:
[code]
that._callbackFire( 'onPostSubmit', [json, data] );
[/code]

here is my code to create the editor. i add the fields right after this.

[code]
//create the editor
var editor = new $.fn.dataTable.Editor({
"domTable": "#is_database",
"ajax": function(method, url, data, successCallback, errorCallback) {
//
//new
//
if(data.action == "create")
{
var arrayToAddToJSON = [];
console.log(data);
var stuff = data.data;
for (var i in stuff)
{
arrayToAddToJSON.push(stuff[i]);
}
var id = window.table_data.length;
window.table_data.push(arrayToAddToJSON);
successCallback({"id" : id});
window.form_script.parent_class.resize_container();
}
//
//edit
//
else if(data.action == "edit")
{
var dataArray = data.data;
for(i in window.table_data[data.id])
{
window.table_data[data.id][i] = dataArray[i];
}
successCallback({});
window.form_script.parent_class.resize_container();
}
//
//delete
//
else if(data.action == "remove")
{
//blank out row in json data, but don't remove from
//the array so editing will still work
//
//row gets removed from array when saved to page
window.table_data[data.data] = [];
successCallback({});
window.form_script.parent_class.resize_container();
}
else
{
alert("Invalid action");
}
}
});

var fields = this.create_fields();
fields = JSON.stringify(fields);
fields = JSON.parse(fields);
[/code]

the table is just a simple html table. i can post it if you want to see it, but i don't think it's necessary.

any help is greatly appreciated!

editor.add(fields);

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi,

    I suspect we probably will need to see an example of it going wrong I'm afraid. I don't see anything obvious from the above code.

    Allan
  • awmitchellawmitchell Posts: 3Questions: 0Answers: 0
    so what exactly do you need from me?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    A link to the page.

    Allan
  • awmitchellawmitchell Posts: 3Questions: 0Answers: 0
    Hm, ok. Let me throw something together that I can put online for you.
  • burncharburnchar Posts: 118Questions: 12Answers: 0
    edited October 2012
    Shot in the dark here but does the data for your row 28 have a null value?
    I've had some problems with nulls. If so, you can either set it to: "" (empty string) before it gets to DataTables or set a default with aoColumns, e.g.:

    [code]
    aoColumns: [
    { "mData": "row28Field", sDefaultContent: "n/a" },
    { "mData": "Alternative", sDefaultContent: "" }
    ]
    [/code]
This discussion has been closed.