CRUD operations with the Scheduler

Hello,

I have been working with the Scheduler component.  I am currently investigating the CRUD operations.  We currently use custom hooks to make api calls to our own api.  That api then will make database changes to our database accordingly.

I'm looking to see if there is a way to control the onClick events of these buttons or remove them and add our own buttons to do so.


If that isn't possible, what would be the recommended action I should take.

Let me know if you need any more information.

Thanks in advance!



3 Replies

RV Ravikumar Venkatesan Syncfusion Team April 8, 2020 12:15 PM UTC

Hi Drew, 

Greetings from Syncfusion support. 

Based on your requirement we have prepared the below sample with the help of popupOpen event. 

Adding custom button to the Editor window 

Step 1: Bind the popupOpen event to the Schedule like the below code. 

    render() { 
        return (<div className='schedule-control-section'> 
        <div className='col-lg-12 control-section'> 
          <div className='control-wrapper'> 
            <ScheduleComponent width='100' height='650px' selectedDate={new Date(2018, 1, 15)} ref={=> this.scheduleObj = t} eventSettings={{ dataSource: this.data }} popupOpen={this.onPopupOpen.bind(this)}> 
              <Inject services={[Day, Week, WorkWeek, Month, Agenda, Resize, DragAndDrop]}/> 
            </ScheduleComponent> 
          </div> 
        </div> 
      </div>); 
    } 


Step 2: Use the below code in the popupOpen event to add custom buttons to the editor window. 

[index.js] 
    onPopupOpen(args) { 
      if(args.type === 'Editor') { 
        // Fetching editor dialog object 
        let dialogObj = document.querySelector('.e-schedule-dialog').ej2_instances[0]; 
        // Fetching the fotter element of the editor window 
        let footer = dialogObj.element.querySelector('.e-footer-content'); 
        // Creting the button element 
        let btnElement = createElement("BUTTON", {innerHTML: "Custom Button"}); 
        // Creting the button object 
        let buttonObj = new Button(); 
        // Appeding the button object to the button element 
        buttonObj.appendTo(btnElement); 
        // Appendig the creted button to the footer of the editor window. 
        footer.appendChild(btnElement); 
        // Binding the evnet to the custom button element 
        buttonObj.element.onclick = () => alert('Custom button click'); 
      } 
    } 
 

Hiding default editor window buttons 

You can hide the default editor window buttons with help of CSS style like below. 

[index.css] 
.e-event-save, .e-event-delete { 
  display: none; 
} 


Kindly try the above sample and get back to us If you would require further assistance. 

Regards, 
Ravikumar Venkatesan 



DM Drew McIlquham April 9, 2020 09:36 PM UTC

Hello,

Thank you for the response!  I want to make sure I understand.  Based on your answer of adding in new buttons and hiding the originals, does that mean that the original buttons onClick events cannot be controlled?


NR Nevitha Ravi Syncfusion Team April 10, 2020 06:06 AM UTC

Hi Drew, 

Thanks for the update. 

We have validated your reported query at our end and modified our previously updated sample using popupOpen event and it can be viewed from the following link. 

Code snippet
  onPopupOpen(args) { 
    if (args.type === 'Editor') { 
      let dialogObj = (args.element).ej2_instances[0]; 
      let buttons; 
      if (args.target.classList.contains('e-appointment')) { 
        this.currentEvent = this.scheduleObj.getEventDetails(args.target); 
        buttons = [{ 
          buttonModel: { content: 'SAVE', isPrimary: true }, click: this.editEvent.bind(this) 
        }, { 
          buttonModel: { content: 'DELETE', cssClass: 'e-event-delete' }, click: this.eventDelete.bind(this) 
        }, 
        { 
          buttonModel: { content: 'CANCEL', cssClass: 'e-event-cancel' }, click: this.dialogClose.bind(this) 
        }]; 
      } else { 
        buttons = [{ 
          buttonModel: { content: 'SAVE', isPrimary: true }, click: this.eventAdd.bind(this) 
        }, { 
          buttonModel: { content: 'CANCEL', cssClass: 'e-event-cancel' }, click: this.dialogClose.bind(this) 
        }]; 
      } 
      dialogObj.buttons = buttons; 
      dialogObj.dataBind(); 
    } 
  } 

Kindly try the sample and get back to us for further assistance. 

Regards, 
Nevitha 


Loader.
Up arrow icon