Hi,
I'm trying to show an alert to the user when he selects a different row than the one he already has selected, but I need to not continue with the selection of this new row, until the user confirms if he really wants to select it (because selecting it will trigger other functions )
const rowSelecting = async (args) => {
if (args.previousRowIndex !== args.rowIndex) {
let resp = await Swal.fire({
title: "¿Está seguro que desea seleccionar otra Operación?",
text: "Puede tener información sin guardar, si continúa se perderán estos registros.",
icon: "warning",
showCancelButton: true,
confirmButtonText: "Continue",
});
if (resp.isDismissed) {
args.cancel = true;
}
/* const resp = window.confirm(
"¿Estás seguro de que desea cambiar de transacción, talvez tiene información sin guardar, si continúa se perderán estos registros.?"
);
//select cancel button
if (!resp) {
args.cancel = true;
} */
}
//... then execute rowSelected event
};
I am using Swal's alerts, but it seems that the rowSelecting event does not wait for the execution of the alert (which I have tried to make it a synchronous function with the await) but with the window.confirm() it works perfectly.
Any suggestions, why do I really need to use the swal alert?