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

Not close event window if error


When the user type the information and click OK button, i want to validate those informations and if was something wrong, i want to show a error message and KEEP the event window opened. I'm using the actionComplete event to validate it.

Is it possible?

Thank you

9 Replies

NR Nevitha Ravi Syncfusion Team April 23, 2019 09:34 AM UTC

Dear Customer, 

Greetings from Syncfusion Support. 

We have prepared a sample to validate the autocomplete control which can be viewed from the following link. 

popupOpen: function (args) { 
    if (args.type === 'Editor') { 
      // Create required custom elements in initial time 
      if (!args.element.querySelector('.custom-field-row')) { 
        var row = new ej.base.createElement('div', { className: 'custom-field-row' }); 
        var formElement = args.element.querySelector('.e-schedule-form'); 
        formElement.firstChild.insertBefore(row, args.element.querySelector('.e-title-location-row')); 
        var container = new ej.base.createElement('div', { className: 'custom-field-container' }); 
        var inputEle = new ej.base.createElement('input', { 
          className: 'e-field' 
        inputEle.setAttribute('name', 'AttendeesArray'); 
        var autoObj = new ej.dropdowns.AutoComplete({ 
          dataSource: members, 
          fields: { value: 'text' }, 
          floatLabelType: 'Always', placeholder: 'Team Members', 
          filtering: function () { 
            if (!ej.base.isNullOrUndefined(document.getElementById("AttendeesArray-info"))) { 
              document.getElementById("AttendeesArray-info").style.display = "none"; 
        var validator = formElement.ej2_instances[0]; 
        validator.addRules('AttendeesArray', { required: true });  
      args.element.ej2_instances[0].open = function () { 

For validating default fields kindly check the online sample demo here and for more details about validation please refer following UG link. 


S_ S_Line April 23, 2019 10:50 AM UTC

Hello, thank you for the assistance.

I understand, but, im doing my own validation on the server when the user click OK and if error, i want to keep the event window opened. 
Is there a way to do this?

Here is my code:

actionComplete: function (args) {
                    if (args.requestType == "eventCreated" || args.requestType == "eventChanged") {
                        var url = "http://www.....";
                        var pars = {
                            "param1": "value1",
                            "param2": "value2",
                            "param3": "value3",
                            "param4": "value4"

                        AjaxMethodCall(url, pars, onSuccess, onError);

                        function onSuccess(param) {
                            //if success, the information was saved on database

                        function onError(xhr, textStatus, errorThrown) {
                            //if error, i want to show message and keep the event window opened

NR Nevitha Ravi Syncfusion Team April 24, 2019 09:35 AM UTC

Dear Customer, 

Thanks for your update. 

We have prepared sample to prevent closing of the editor window if the value of autoComplete control is Maintenance which we have done in actionBegin event since in actionComplete the event will be created that will not be a proper way. Please refer the following sample. 

actionBegin: function (args) { 
    if (args.requestType === 'eventCreate' || args.requestType === 'eventChange') { 
      var eventType = (args.requestType === 'eventCreate') ? args.data[0].EventType : (args.data).EventType; 
      if (eventType == 'Maintenance') { 
        args.cancel = true; 
        flag = true; 
        scheduleObj.eventWindow.dialogObject.beforeClose = function (args) { 
          args.cancel = flag; 
          if (flag) alert('Maintenance not allowed now'); 
          flag = false; 


S_ S_Line April 24, 2019 11:29 AM UTC

THANK YOU! it help me a lot!!

NR Nevitha Ravi Syncfusion Team April 24, 2019 01:01 PM UTC

Dear Customer, 
We are glad that our solution helped you. Please let us know if you need further assistance. 

IV Ivan October 11, 2019 05:48 PM UTC

Is this up-to-date answer?

The example from previous answer not working on StackBlitz.

As I see, actionBegin is called only on first click on a Save button.

I have custom Editor template and server side validation. For me, expected behavior is on every Save send all data to server for validation and in case of any errors show them in dialog ( not closing ).


HB Hareesh Balasubramanian Syncfusion Team October 14, 2019 12:23 PM UTC

Dear Customer, 

Thanks for your update. 

We have prepared the below sample to close the editor only on success action using actionBegin and actionComplete events. 

  actionBegin: function (args) { 
    if (!ej.base.isNullOrUndefined(document.querySelector('.e-schedule-dialog'))) { 
      var scheduleObj = document.querySelector('.e-schedule').ej2_instances[0]; 
      scheduleObj.uiStateValues.isBlock = true; 
  actionComplete: function (args) { 
    if (!ej.base.isNullOrUndefined(document.querySelector('.e-schedule-dialog'))) { 
      var diaObj = document.querySelector('.e-schedule-dialog').ej2_instances[0]; 
      var scheduleObj = document.querySelector('.e-schedule').ej2_instances[0]; 
      scheduleObj.uiStateValues.isBlock = false; 

Kindly try the above sample, if you have any concerns please revert us back for further assistance. 


IV Ivan October 21, 2019 09:08 AM UTC


at first I have a problem with adding AJAX call to server (complete request were repeated in infinite loop). But now is ok. 

Tnx for support!

VD Vinitha Devi Murugan Syncfusion Team October 22, 2019 06:30 AM UTC

Hi Ivan, 
Thanks for your update. 
We are pleased that your problem has been resolved.  
M.Vinitha devi 

Live Chat Icon For mobile
Up arrow icon