Hello and thank you for your kind help. I do have the following simple grid:
I want people to click the checkbox BUT before that, I want a dialog to appear saying: "are you sure? " (or another msg), if they do not confirm then nothing happens, I hope make sense what I said.
So for all other columns, I'm using "finalizeCellEdit" and it works as expected, now on the checkbox column, I tried to use it and simply does nothing, even if finalizeCellEdit is listed as a valid property, so I decided to take another approach using beforeToggle event, and it works only if it runs synchronously and I need this to be async, as I have to wait for the answer of the user, here's a sample of my code:
Any help on this situation will be appreciated. Thank you.
Re: Checkbox column confirmation before toggle
Posted: Mon Feb 21, 2022 4:41 pm
by mats
For now you would need to return false from beforeToggle, save a reference to the record / checkbox and show your popup and then set the checked value based on the user input.
Re: Checkbox column confirmation before toggle
Posted: Mon Feb 21, 2022 4:51 pm
by sipi41
ok, let me see if I understood... so I should always return false, that's the easy part, then... create another function and send a reference of the record? then update accordingly? would you please provide an example? thanks for your help.
May I ask why finalizeBeforeEdit is not working???
Re: Checkbox column confirmation before toggle
Posted: Mon Feb 21, 2022 7:09 pm
by sipi41
Ok... any example on how to do this? how do I put a confirmation before accepting checkbox new value? thanks for all your help.
Re: Checkbox column confirmation before toggle
Posted: Mon Feb 21, 2022 11:26 pm
by mats
Try:
{
type : 'check',
field : 'done',
flex : 2,
listeners : {
beforeToggle({ checked, record }) {
const result = MessageDialog.confirm({
title : 'Please confirm',
message : 'Did you want this?'
}).then(result => {
if (result === MessageDialog.okButton) {
record.done = checked;
}
});
return false;
}
}
},
Re: Checkbox column confirmation before toggle
Posted: Tue Feb 22, 2022 1:19 am
by sipi41
Mr Mats, thank you for the great sample and your patience, we still have more question but this one is resolved I think.
PD. for other people, record.done does not exist, that is RECORD.YOURFIELD = true in this case, so you are not looking for this DONE option.