Adding a switch button to a scheduler default view

Hello,

Currently I am using default functionality of scheduler and my event looks like the following:



What I am trying to do is to add a button switch to the template.


While I was somewhat able to add this button switch to the template through onPopupOpen function I was not able to add it when the event is readonly. Could you please guide me in the right direction


1 Reply

RM Ruksar Moosa Sait Syncfusion Team January 20, 2022 08:56 AM UTC

Hi Misha,


You can add the Switch button to the QuickInfo popup and bind to the onPopupOpen method like the below code snippet.


onPopupOpen(argsPopupOpenEventArgs): void {

    if (args.type === 'QuickInfo') {

      // Create switch element in the initial time

      if (!args.element.querySelector('.custom-switch-button')) {

        let
rowHTMLElement = createElement('div', {

          className:
'custom-switch-button',

        });

        let
formElementHTMLElement =

          args.element.querySelector('.e-popup-header');

        formElement.firstChild.insertBefore(

          row,

          args.element.querySelector('.e-edit')

        );

        let
containerHTMLElement = createElement('div', {

          className:
'custom-switch-container',

        }) as
HTMLElement;

        let
inputEleHTMLInputElement = createElement('input', {

          className:
'e-field',

          attrs: { name:
'EventType' },

        }) as
HTMLInputElement;

        container.appendChild(inputEle);

        row.appendChild(container);

        let
switchObjSwitch = new
Switch({

          name:
'hotspot',

          value:
'USB tethering',

          checked:
true,

        });

        switchObj.appendTo(inputEle);

        inputEle.setAttribute('name''hotspot');

      }

    }

  }


Also the Switch button works fine when the events are set to IsReadonly: true like the below image.



Sample: https://stackblitz.com/edit/angular-adding-switch-button?file=app.component.ts


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


Regards,

Ruksar Moosa Sait


Loader.
Up arrow icon