Editor, ajax-data
Editor, ajax-data
Hi, please help as i am Editing the table with Editor.
editor = new $.fn.dataTable.Editor({
ajax: {
edit: { type: 'PUT',
url: '/customer',
data: function ( d ) {
var ownData = {data: d.data[1]};
return JSON.stringify( ownData );}
},
the console output as follows:
{"data":{"0":"1","1":"","2":"423015","3":"...
BUT my servlet class need jason-formatted data as follow
[{"no":"1","col":"","row":"423015",....
Please help how to reformat editor data to match my servlet class?
thank you
This question has an accepted answers - jump to answer
Answers
You can use the
ajax.data
option to transform the data from what Editor submits to that which your server-side requires.The parameters Editor sends are documented here.
Allan
Dear Allan,
thank you for the direction, and the problem is solved.
by reformatting (correcting "Fields") below:
editor = new $.fn.dataTable.Editor({
ajax: {
edit: {
type: 'PUT',
url: '/customer',
contentType: 'application/json',
data: function ( d ) {
var ownData = d.data[1];
return JSON.stringify(ownData);}}},
table: '#example',
idSrc: '0',
fields: [
{label:'No :', name:'no', data:'0'},
{label:'Notes :', name:'col', data:'1'},
{label:'NoWo :', name:'row', data:'2'},
....]
Thank you.