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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Not close event window if error

Thread ID:

Created:

Updated:

Platform:

Replies:

144156 Apr 22,2019 08:47 PM UTC Oct 22,2019 06:30 AM UTC JavaScript - EJ 2 9
loading
Tags: Schedule
S_Line
Asked On April 22, 2019 08:48 PM UTC

Hi,

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

Nevitha Ravi [Syncfusion]
Replied On 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'); 
        container.appendChild(inputEle); 
        row.appendChild(container); 
        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"; 
            } 
          } 
        }); 
        autoObj.appendTo(inputEle); 
        var validator = formElement.ej2_instances[0]; 
        validator.addRules('AttendeesArray', { required: true });  
      } 
      args.element.ej2_instances[0].open = function () { 
        autoObj.focusIn(); 
      } 
    } 
  } 


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

Regards, 
Nevitha 


S_Line
Replied On 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
                        }
                    }
                },

Nevitha Ravi [Syncfusion]
Replied On 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; 
        } 
      } 
    } 
  } 

Regards, 
Nevitha 


S_Line
Replied On April 24, 2019 11:29 AM UTC

THANK YOU! it help me a lot!!

Nevitha Ravi [Syncfusion]
Replied On 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. 
  
Regards, 
Nevitha 


Ivan
Replied On 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 ).

Thanks!

Hareesh Balasubramanian [Syncfusion]
Replied On 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; 
      diaObj.hide(); 
   
 


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

Regards, 
Hareesh 


Ivan
Replied On October 21, 2019 09:08 AM UTC

Tnx!

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!



Vinitha Devi Murugan [Syncfusion]
Replied On October 22, 2019 06:30 AM UTC

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon