The function in replacements of ajax wont be fired
The function in replacements of ajax wont be fired
Hi all, excuse me.
I'll appreciated if someone can give me advise.
I cannot get the current DT_RowID after I click the update butten. my api has retrieved the ajax data from the editor, but I still need to process before the ajax data send.
Thanks!
editorList = new $.fn.dataTable.Editor({
ajax: {
edit: {
url: MyApiUrl,
headers: {
Authorization: 'Bearer ' + jsApiToken
},
contentType: "application/json",
method: 'put',
replacements: {
controller: function (key, id, action, data) {
console.log('this function won't be fired after the update button has been click);
return id;
}
},
data: function (d) {
console.log('need to get the DT_RowID before send the ajax data');
return JSON.stringify(d);
}
}
}
Answers
If you use the "select" extension you can get the id of the row selected for editing.
https://datatables.net/extensions/select/
Using that you can do something like this:
You can also retrieve the rowId on "preSubmit".