Editor Duplicate button form not submitting json object
Editor Duplicate button form not submitting json object
sarath_surisetty
Posts: 54Questions: 13Answers: 0
in Editor
i had included Duplicate button for the editor,when clicked on button the form popup is generated with the data selected for duplicate, but the actual problem is when i click create button, data not posted like object how it posted when i used add button.instead it is posting like datatable input.
Could you please support in achieving the format how the add button form post works?
CODE:
buttons: [
{ extend: "create", editor: propertyEditor },
{ extend: "edit", editor: propertyEditor },
{
extend: "selected",
text: 'Duplicate',
action: function ( e, dt, node, config ) {
// Start in edit mode, and then change to create
propertyEditor
.edit( PropertyTable.rows( {selected: true} ).indexes(), {
title: 'Duplicate record',
buttons: 'Create from existing'
} )
.mode( 'create' );
}
},
{ extend: "remove", editor: propertyEditor },
{
text: 'Reload',
action: function ( e, dt, node, config ) {
dt.ajax.reload();
}
}
]
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I'm not certain as you don't say, but I've just answered a very similar question by someone else, and they are using the
ajax
option to define different options for Ajax submission of data. I'm guessing that is the same here.This was my reply:
The issue here is that the data in
d.data
doesn't have an index 0. Instead try:That will convert the object (or an array if it really is a create action) to an array and then use that to submit to the server.
Regards,
Allan
hi allan
i have already ajax for editor :
it is working as expected for create(add),edit,remove.
problem is when duplicate button implemented.
reference link : https://editor.datatables.net/examples/api/duplicateButton.html
It looks like you haven't tried adding the code I suggested above. The issue is that the
addData
value has a primary key row identifier from the edit, so you need to map it down to a plain array.Allan
It worked thank allan