Validation does not function on edit method

Hello. I tried to add validations for the create and edit methods of my scheduler. These validations work for the create method, but do not work for the edit method. Please note that I was unable to use "click: this.scheduleObj.eventWindow.eventSave.bind (this.scheduleObj.eventWindow)" for the edit button, because the data is passed on the OnActionBegin method with request-type eventCreate and so I could not perform the edit action.

Here is the simple reproduction of the problem :

https://stackblitz.com/edit/react-qpyuri-uujhyv?file=index.js

Do you think you can help me add validations for the edit method and send the data to onActionBegin with the "eventChange" requestType?


5 Replies

SK Satheesh Kumar Balasubramanian Syncfusion Team June 13, 2022 12:52 PM UTC

Hi Cezar,

You can use the same eventSave function which is used for create to resolve the reported issue.


index.js:

        dialog.buttons = [
          {
            buttonModel: {
              content: 'Delete',
              cssClass: 'e-primary e-event-delete e-hide',
            },
          },
          {
            buttonModel: {
              content: 'Cancel',
              cssClass: 'e-event-cancel e-hide',
            },
            click: this.scheduleObj.eventWindow.dialogClose.bind(
              this.scheduleObj.eventWindow
            ),
          },
          {
            buttonModel: {
              content: 'Edit',
              cssClass: 'e-primary e-event-save',
              isPrimary: true,
              allowDragAndDrops: false,
            },
            //click: this.eventEdit.bind(this),
            click: this.scheduleObj.eventWindow.eventSave.bind(
              this.scheduleObj.eventWindow
            ),
          },
        ];

Kindly try the above sample and let us know if this meets your requirement.

Regards,
Satheesh Kumar B


CE Cezar June 13, 2022 11:03 PM UTC

Hi,Satheesh Kumar .

If I try as you suggested, the validations work, but there is another problem when the data is passed  to the OnActionBegin method, event  is sent with the "eventCreated" requestType and not "eventChanged" as it should normally be when Edit button was pressed

That's what I tried to explain at the beginning of the thread.

I am attaching 2 solutions (Back End and Front End) where I replicated the problem.


Attachment: ValidationProblemApps_3943082e.rar



RM Ruksar Moosa Sait Syncfusion Team June 15, 2022 01:14 PM UTC

Hi Cezar,


We have checked on your shared codes and let you know that the eventData was tried to ‘Add’ in the openEditor method which resulted in requestType as eventCreate in the OnActionBegin method. Hence, we suggest you frame the Id value and pass it to the openEditor method in the OnPopupOpen method like the below code snippet to overcome the reported issue.


let eventData = {

                Id: args.data.Id,

                StartTime: args.data.StartTime,

                EndTime: args.data.EndTime,

                SubjectId: subject.Id,

                Subjects: subjects,

                Classes : classes,

                ClassId : currentClass.Id

            };

    this.scheduleObj.openEditor(eventData, args.data.Id ? 'Save': 'Add', true);

    dialog.headerEle.querySelector('.e-title-text').innerText = 'Actualizeaza interval orar';


Kindly try the above solution and let us know if this meets your requirement.


Regards,

Ruksar Moosa Sait



CE Cezar June 15, 2022 05:36 PM UTC

Thank you very much Ruksar Moosa , it works !




SK Satheesh Kumar Balasubramanian Syncfusion Team June 16, 2022 05:10 AM UTC

Hi Cezar,

Thanks for the update.

We are happy that your problem has been resolved now.

Regards,

Satheesh Kumar B


Loader.
Up arrow icon