- Home
- Forum
- ASP.NET Core - EJ 2
- Add and remove blocked events in scheduler
Add and remove blocked events in scheduler
Hi,
I would like to know how to add and remove blocked slots in the scheduler.
I can do it by adding events with IsBlocked set to true in database but I would like that some users (managers) can have the possibility to remove thoses blocked event.
As it is working in the demo, the blocked slots cannot be edited:
https://ej2.syncfusion.com/aspnetcore/Schedule/BlockEvents#/material
Thank you
SIGN IN To post a reply.
3 Replies
BS
Balasubramanian Sattanathan
Syncfusion Team
January 8, 2021 09:01 AM UTC
Hi Paskal,
Greetings from Syncfusion Support.
We have validated your requirement at our end and let you know that we can achieve it by using dataBound event. And also we can provide the access to deleting the block events based on users by using below highlighted code snippet.
|
var userName = "Manager";
function onDataBound() {
var blockElements = document.querySelectorAll('.e-block-appointment');
if (userName === "Manager") {
for (var i = 0; i < blockElements.length; i++) {
blockElements[i].onclick = onBlockClick;
}
}
};
function onBlockClick(args) {
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
var totalCount = schObj.getBlockEvents();
var currentId;
if (args.target.classList.contains('e-block-appointment')) {
currentId = parseInt(args.target.getAttribute("data-id").split('_')[1]);
} else {
currentId = parseInt(args.target.offsetParent.getAttribute("data-id").split('_')[1]);
}
var currentBlockData = [];
for (var i = 0; i < totalCount.length; i++) {
if (totalCount[i].Id === currentId) {
currentBlockData.push(totalCount[i]);
}
}
schObj.deleteEvent(currentBlockData);
} |
Kindly try the above solution and let us know if you need further assistance.
Regards,
Balasubramanian S
PT
Pascal Thomé
January 11, 2021 07:18 PM UTC
Hi Balasubramanian,
Thanks for your response. The deleting of block events is working with your code.
Now i would like to add and edit thoses block events and I am facing another difficulty.
I replaced schObj.deleteEvent(currentBlockData); with schObj.openEditor(currentBlockData, "Save"); in onBlockClick(args) to open the editor.
The editor opens and I managed to add a checkbox IsBlock in onPopupOpen(args) but when I save I have this error :
event-window.js:1206 Uncaught TypeError: Cannot read property 'RecurrenceRule' of undefined
at e.processCrudActions (event-window.js:1206)
at e.<anonymous> (event-window.js:244)
at e.notify (observer.js:84)
at t.e.trigger (base.js:181)
at e.onBeforeClose (event-window.js:224)
at e.notify (observer.js:99)
at t.e.trigger (base.js:181)
at t.hide (dialog.js:1295)
at e.eventSave (event-window.js:1141)
editedData is undefined at line event-window.js:1206 -> if (!isNullOrUndefined(editedData[this.fields.recurrenceRule]))
I see that it is undefined because editedData is defined only based on the eventsData list and the block events are in another list called blockData
How can I manage to add and edit block events ?
Thanks for your help
Pascal
NR
Nevitha Ravi
Syncfusion Team
January 12, 2021 11:15 AM UTC
Hi Pascal,
Thanks for your update.
We could replicate the reported problem “block events can’t be edited using editor window” and confirm this as defect. We have logged the bug report which can be tracked from the following link.
The issue fix will be included in our weekly patch release scheduled on January 26, 2021. In the meantime you can use saveEvent public method by passing the updated event to the method.
Regards,
Nevitha
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
PT Pascal Thomé
- Jan 7, 2021 09:32 PM UTC
- Jan 12, 2021 11:15 AM UTC