DataTabled Editor error after POST
DataTabled Editor error after POST
Hi,
I'm testing the Editor as a Demo. I have a Table with inline-edit and a language select-field
On page load, the data is rendered into the columns as expected, the inline-selection works as well.
After leaving the cell, the data is POSTed to the server correctly, and a correct json (including the changed values) is returned by the server. However I'm getting an error of DataTables saying:
DataTables warning: table id=address-table - Requested unknown parameter 'language.plain' for row 1. For more information about this error, please see http://datatables.net/tn/4
I fail to see what's wrong (the inital JSON data and the response are correct). Why does DataTables complain about the parameters after POSTing?
Maybe there is something wrong with the (kind of weird way) I'm rendering the language column?
The idea behind this is, that the user should see a nicely formatted value ("English"), while the server needs to get a 2-letter value ("en"). Is there a better way to handle an object like { display: "English", plain: "en" }
?
My data (on page load) looks like this:
data [
{
DT_RowId: "row_1",
language: { display: "English", plain: "en" }
}
]
The Table is defined as:
$("#address-table").DataTable({
ajax: " ... ",
columns: [
{data: "language.plain", "render": function ( data, type, full, meta ) {
return full.language.display;
}}
]
});
The Editor is defined as:
addressEditor = new $.fn.dataTable.Editor({
ajax: " ... ",
fields: [
{name: "language.plain",
label: "Sprache",
type: "select",
ipOpts: [{ label: "English", value: "en"}, { label: "German", value: "de"}]
}
]
});
The data POSTed (after selecting "German" in table):
action:edit
data[language][plain]:de
The servers response:
data [
{
DT_RowId: "row_1",
language: { display: "German", plain: "de" }
}
]
Replies
Hi,
Thanks for all the details! The problem is that Editor expects a slightly different format to its Ajax requests than DataTables does. The data for the row is the same format, but since Editor (currently) only operates on a single row at a time when editing, a simple
row
object is expected in return for the edited row.The client / server communication that Editor uses is documented here. For your example you might have:
as the returned JSON data.
Regards,
Allan
Hi Allan,
thanks! That solved my issue :)
Regards,
Tim