Editor script on changed value
Editor script on changed value
I have a table set up like this (simplified for the exemple):
var editor = new DataTable.Editor({
idSrc: "NUMBER",
fields: [
{
"label": "Ready",
"name": "Ready",
"type": "select",
options: [
{ label: '✖', value: null },
{ label: '✔', value: '1' },
]
},
table: "#exemple"
});
var table = new DataTable("#cloture", {
language: {
url: staticUrl,
},
ajax: {
url: 'myjsonurl',
type: "GET",
dataType: "json",
dataSrc: '',
},
buttons: [
{ extend: "searchBuilder", className: "buttons-searchBuilder w-100 h-100 p-3" },
{ extend: "edit", className: "w-100 h-100 p-3", editor },
],
columns: [
// DOSSIER PERMANENT
{ data: "NUMBER", name:"NUMBER" },
{ data: "NAME", name:"NAME" },
{ data: "ADRESS", name:"ADRESSE" },
{ data: "READY", name:"READY", className: "editable",
render: function (data, type){
if (type === "display"){
if (data == null) {
return "✖";
} else if (data == "1") {
return "✔";
}
} else if (type === "sort" || type === 'filter' ){
if (data == null) {
return '0';
} else if (data == "1") {
return "1";
}
}
return data;
}
},
dom: "Bfrtip",
select: true,
processing: true,
deferRender: true,
scrollX: true,
pageResize: true,
});
What i want to do is send a mailto when the data in the "READY" column is changed. The bellow script isn't trigger, can you help me to trigger this script when the data in the ready column is send / changed.
$('#exemple').on( 'change', 'td:nth-child(4)', function () {
var rowData = table.row($(this).closest('tr')).data();
var BilanPret = rowData['READY'];
if (BilanPret == 1) {
// send the mailto here
console.log('test)
}
});
Thank for your time / answer,
Mathieu.
Edited by Allan - syntax highlighting
This question has an accepted answers - jump to answer
Answers
Hi Mathieu,
td
cells don't trigger achange
event.input
elements do, but not other elements.Listen for Editor's
submitComplete
event and trigger your e-mail there.Allan
Hi Allan,
Thank for your answers , it almost work, is it possible to get value of row / cell in submitComplete function ?
The
json
parameter has the JSON data returned from the server, possibly you can use that. Or thedata
parameter has the data sent to the server. Do either of these contain what you are looking for.Kevin