Our pure JavaScript Scheduler component


Post by eugenem »

I'm trying to catch task editor before closing to do some validations, and it's not working:

taskEditFeature: {
      editorConfig: {
        autoClose: false,
        listeners: {
          show() {
            const taskRecord = this.record;
            // this one works
          },
          beforeHide: (event, source) => {
            this.console.debug(event, source);
            // this one doesn't
          },

there is the reference:
https://www.bryntum.com/docs/scheduler-pro/api/SchedulerPro/widget/SchedulerTaskEditor#event-beforeHide


Post by eugenem »

What I actually need is to cath 'ok' click and warn if there are some issues. So maybe there is a better way...


Post by mats »


Post by eugenem »

don't get anything there

listeners: {
          show() {
          },
          beforeTaskSave: (event, source, taskRecord, editor) => {
            this.console.debug(event, source, taskRecord, editor);
          },
          

Post by mats »

You should attach the listener to the SchedulerPro instance

 /**
     * Fires on the owning Scheduler Pro instance before a task is saved
     * @event beforeTaskSave
     * @on-owner
     * @param {SchedulerPro.view.SchedulerPro} source The Scheduler Pro instance
     * @param {SchedulerPro.model.EventModel} taskRecord The task about to be saved
     * @param {SchedulerPro.widget.TaskEditorBase} editor The editor widget
     * @preventable
     */

Post by eugenem »

ah, silly me. I'm doing this already...


Post by eugenem »

A related question: can I catch any change at the editor? Like not waiting for a user to try to save, but validate stuff in real-time.


Post by alex.l »

You can listen to changes in fields if you want.
As example, subscribe on fields events here https://bryntum.com/docs/scheduler-pro/api/SchedulerPro/feature/TaskEdit#event-beforeTaskEditShow

editor has widgetMap property that contains all specified widgets.
https://bryntum.com/docs/scheduler-pro/api/Core/widget/Container#property-widgetMap

Or you could specify listeners using eventEditor config.
Full information how do that you can find here: https://bryntum.com/docs/scheduler-pro/guide/SchedulerPro/basics/taskedit

All the best,
Alex


Post by eugenem »

ok, and how can I add some custom block to the editor? I'll show there validation messages. not your standard control...


Post by alex.l »

Check the guide here: https://bryntum.com/docs/scheduler-pro/guide/SchedulerPro/basics/taskedit
And docs here: https://bryntum.com/docs/scheduler-pro/api/Scheduler/feature/EventEdit#adding-custom-widgets

You just need to pass a config to specify a new field (block) you want to put into the editor.

const scheduler = new Scheduler({
    features : {
        eventEdit : {
            items : {
                // Key to use as fields ref (for easier retrieval later)
                colorCustomField : {
                    type  : 'combo',
                    label : 'Color',
                    items : ['red', 'green', 'blue'],
                    // name will be used to link to a field in the event record when loading and saving in the editor
                    name  : 'eventColor'
                }
            }
        }
    }
})

Here is an online example https://bryntum.com/examples/examples-scheduler/eventeditor/

All the best,
Alex


Post Reply