- Home
- Forum
- JavaScript - EJ 2
- Not close event window if error
Not close event window if error
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
SIGN IN To post a reply.
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');
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_
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:
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;
}
}
}
}
Regards,
Nevitha
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.
Regards,
Nevitha
IV
Ivan
October 11, 2019 05:48 PM UTC
Is this up-to-date answer?
The example from previous answer not working on StackBlitz.
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!
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!
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;
diaObj.hide();
}
} |
Kindly try the above sample, if you have any concerns please revert us back for further assistance.
Regards,
Hareesh
IV
Ivan
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!
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.
Regards,
M.Vinitha devi
SIGN IN To post a reply.
- 9 Replies
- 5 Participants
-
S_ S_Line
- Apr 22, 2019 08:47 PM UTC
- Oct 22, 2019 06:30 AM UTC