Hello,
I am clear, and I have reviewed it on multiple occasions, that the event where I have to control is: "onaction = {Handleclick}".
Now, I have it controlled in the case of "Add" through the values of "ev.changes", since in that case, if there is no informed field the number of changed records is "0".
But in the case of "Edit", change or not change value, the fields of "ev.changes" are always all fields.
How do I know if there are changes? This condition is evaluated by its code.
`
// Manejo de acciones del editor
function handleClick( ev) {
// need to check that there are changes and close editor after successful validation
// otherwise, even if "save" event is not triggered, editor will be closed anyway
// but we still can close editor if there are not any changes
console.log ("handleClick: ", ev.item);
const changes = ev.changes;
const values = ev.values;
const item = ev.item;
console.log("handleClick:", ev);
console.log("Cambios:", changes.length);
console.log("Valores Cambiados:", values);
console.log("Keys de Values:", Object.keys(values).length);
console.log("Modo editor:", editorMode);
if (item.id === "save" && changes.length === 0 && Object.keys(values).length == 0 && editorMode == "add") {
addToast({
message:'Se deben completar los datos del formlario o cliquear Cancelar' ,
type: 'error',
dismissible: true,
timeout: 4000
});
console.warn("ADD - No hay cambios para guardar.");
}
if (item.id === "cancel" || item.id === "close") closeEdit();
}
`
Greetings,