Page 1 of 1

Checkbox column confirmation before toggle

Posted: Mon Feb 21, 2022 4:22 pm
by sipi41

Hello and thank you for your kind help. I do have the following simple grid:

Image

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:

Image

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.


Re: Checkbox column confirmation before toggle

Posted: Wed May 31, 2023 1:52 am
by sprabhu

Hi Mats,
The above code is not working when I try to implement on the advanced example provided by Bryntum.
Please refer to the recoding using the link : https://frontrol-my.sharepoint.com/:v:/p/cgupta/EYdzTia8qjRFtrcn7EepWRQBCJfu16Q29pD_ahzjTjOf0g?e=TDlgbj

{
                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: Wed May 31, 2023 12:28 pm
by tasnim

Hi,

You need to import the MessageDialog

Screenshot 2023-05-31 162751.png
Screenshot 2023-05-31 162751.png (46.81 KiB) Viewed 469 times

Then, it will be working as expected


Re: Checkbox column confirmation before toggle

Posted: Thu Jun 01, 2023 7:26 am
by sprabhu

its working :-)