We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Prevent appointment window deletion from closing after remove click

Hello!

I've already asked a similar question here https://www.syncfusion.com/forums/141540/prevent-new-appointment-window-from-closing-after-save-click but I think the behavior of the appointment deletion is different.

After I click "remove", a confirmation window appears and I think that's what's causing my code not to work.





And this is the code I'm using:

onActionBegin:

            if (args.requestType === 'eventRemove') {

                var removeData = args.data[0];

                if (removeData.Status !== "Agendada") {
                    args.cancel = true;
                    blockDelete = true;
                    return;
                }
            }

onDataBound:

            var scheduleObj = document.getElementById('schedule').ej2_instances[0];

            scheduleObj.eventWindow.dialogObject.beforeClose = function (args) {

                if (blockEdit === true) {
                    args.cancel = blockEdit;
                    blockEdit = false;
                    alert("A aula já foi realizada. Não é possível alterar a mesma.");
                    return;
                }
                // This code is not getting executed
                else if (blockDelete === true) {
                    args.cancel = blockDelete;
                    blockDelete = false;
                    alert("A aula já foi realizada. Não é possível remover a mesma.");
                    return;
                }
            }
        }

What am I doing wrong?

Thank you!

5 Replies

GP Gregory Perozzo March 1, 2019 04:39 PM UTC

Hello,

Anyone can help?


GP Gregory Perozzo March 4, 2019 02:00 PM UTC

Hello,

Already resolved this by using the Readonly property of a schedule event.

Thank you very much.


NR Nevitha Ravi Syncfusion Team March 5, 2019 09:18 AM UTC

Hi Gregory, 

 
We regret for the delayed post. 

 
We have checked the reported problem at our end which is due to actionBegin will trigger only after the delete confirmation dialog. So we have prepared the sample for your requirement by opening the editor manually using openEditor public method which can be downloaded from the following link. 

 
<Code> 
<script type="text/javascript">
var flag = false;
function onActionBegin(args) {
 if (args.requestType === 'eventCreate' || args.requestType === 'eventChange') {
var subject = (args.requestType === 'eventCreate') ? args.data[0].Subject : (args.data).Subject;
if (subject == 'New') {
args.cancel = true;
flag = true;
}
}
if (args.requestType === 'eventRemove') {
var sub = args.data[0].Subject;
if (sub == 'Meeting') {
args.cancel = true;
 var sch = document.querySelector(".e-schedule").ej2_instances[0];
 sch.openEditor(args.data[0], "Save");
}
}
}
function onDataBound() {
var scheduleObj = document.getElementById('schedule').ej2_instances[0];
scheduleObj.eventWindow.dialogObject.beforeClose = function (args) {
args.cancel = flag;
flag = false;
}
}
</script> 
</Code> 

 
Regards, 
Nevitha 



GP Gregory Perozzo March 5, 2019 08:47 PM UTC

Hi Nevitha,

How are you?

No problem! Thank you very much for your response anyway!

Have a nice day!



KK Karthigeyan Krishnamurthi Syncfusion Team March 6, 2019 03:41 AM UTC

Hi Gregory,

Thanks for your update.

Regards,
Karthigeyan


Loader.
Live Chat Icon For mobile
Up arrow icon