Our pure JavaScript Scheduler component


Post by schwegler-solutions »

Hi! I've updated Scheduler from 4.1.5 to 4.3.8 and discovered that when event creation is triggered (by double-click or from the context menu or by event drag create feature) - a placeholder event is created. Previously, returning <false> in beforeEventEdit listener was preventing this behavior.

Screenshot 2022-02-10 080623.png
Screenshot 2022-02-10 080623.png (14.45 KiB) Viewed 608 times

Please suggest how to get rid of creating empty placeholder events.


Post by alex.l »

Hi schwegler-solutions,

If you don't want to create events on dblclick, set https://bryntum.com/docs/scheduler/api/Scheduler/view/SchedulerBase#config-createEventOnDblClick on false
If you don't want to allow create events from the context menu, hide that option using https://bryntum.com/docs/scheduler/api/Scheduler/feature/ScheduleMenu settings.

const scheduler = new Scheduler({
    features : {
        scheduleMenu : {
            items : {
                addEvent : false
            }
        }
    }
});

For EventDragCreate feature, check its own events, or disable it https://bryntum.com/docs/scheduler/api/Scheduler/feature/EventDragCreate

All the best,
Alex


Post by schwegler-solutions »

Thank you for the response.
Thing is that I don't want to turn off the event listeners. The aim is to still be able to create events, but with custom handling - without creating placeholder events on the clicked area as it was before the update.


Post by schwegler-solutions »

The property I was looking for is https://bryntum.com/docs/scheduler/api/Scheduler/view/SchedulerBase#event-beforeEventAdd

The issue is resolved, thank you.


Post by mils »

Hi schwegler-solutions,
same issue here, can you please detail how you was able to solve using the event beforeEventAdd?

Best regards,


Post by mats »

const scheduler = new Scheduler({
    listeners : {
        beforeEventAdd() {
             return false; // or true
        }
    }
});

Post by mils »

Hi mats,

thanks a lot for your prompt response.
I still can't solve the issue:
- if the function

return false

the event beforeEventEdit doesn't fire no more so I'm unable to open the custom edit event
dialog;

  • if the function
    return true
    the event beforeEventEdit fire correctly but the placeholder Object.NewEvent is still
    generated and I'm unable to avoid this behavior.

Best regards


Post by tasnim »

Hi,
I just found a way to achieve that.
So to achieve that you don't need to use the beforeEventAdd event. It is doable with beforeEventEdit.
So in the beforeEventEdit Handler function

        beforeEventEditHandler(event) {
            // check if it's creating an event or not
            if(event.eventElement.classList.contains('b-iscreating')) {
                // make the placeholder event invisible
                document.querySelector('.b-iscreating[data-task-feature="event"]').style.display = 'none';
            }
            // Open the editor
            this.openEditor(event);
            return false;
        }

Second thing is to display the event when it is saved.
So you need to add some code in the Save event listener.

Add this code in the save event listener before you do something like this.$emit('close').

// check if it is available
if (document.querySelector('.b-sch-event[style="display: none;"]')) {
	// make it visible on the ui
	document.querySelector('.b-sch-event[style="display: none;"]').style.display = null;
}

This should solve your issue.
Please let us know if it solves the issue for you.

Good Luck :),
Tasnim


Post by mils »

Hi Tasnim,

thanks a lot for your response.
This solution seems to work, but just for the first time. The second time I create a new event the placeholder Object.NewEvent is still generated.
Just a precisation: I'm using Angular 13 and Angular wrapper, I followed this thread just because my problem was the same.
I don't know if it makes any difference.

Best regards


Post by tasnim »

Could you please wrap your app in a .zip file and post it here so we can debug it and give you the solution right away?


Post Reply