samureira
samureira

Reputation: 263

How to populate Kendo Scheduler with events having a specific duration/time?

I want to do something like this on my Kendo Scheduler widget:

I double click on the scheduler, I choose the start day and the end day. Then, when I choose event "x" or event "y", (it doesn't matter), I want the pop-up to populate my scheduler with the specific hours of one event. I mean, just like I created in the database different colors for all my events.

For example, I have an event that is called "morning training" and that event, is always from 08h to 16h. So, everytime I choose that event on my pop-up window I don't want to lose time to always pick the hours from 08h to 16h. I already know that such event will be always at that hour so, I would like to avoid picking the hours by myself. Due to that, the datatimepickers wouldn't be needed.

Basically, I would pick the event I want and once I click save, the horizontal bar would be draw into the scheduler from 08h to 16h without me "telling" anything. I would specify the hours for these events on my database, just like I specified colors for them.

Another way I can explain my desired options is this one:

I want to pick two events for me in the same day. I want to double-click on my pop-up window and pick "morning training" (08h to 16h) and "afternoon training" (16h to 00h) at the same time. When I click save, the scheduler would be populated with two different horizontal bars separated by time and not above eachother.

Feel free to ask me anything for me to provide you more insight about my doubts.

Upvotes: 0

Views: 299

Answers (1)

chiapa
chiapa

Reputation: 4412

Using the trigger approach I mentioned in my comment, it would be something like this:

CREATE TRIGGER some_trigger ON tbl_EventType
FOR INSERT AS
SELECT @idEventType=(idEventType) FROM INSERTED
SELECT @startTime=(startTime) FROM tbl_EventType where idEventType = @idEventType
SELECT @endTime=(endTime) FROM tbl_EventType where idEventType = @idEventType

INSERT INTO 
tbl_Event
(idEventType, startTime, endTime)
VALUES
(
@idEventType, @startTime, @endTime
)

On the insert statement, you must add the rest of the fields you have in your table. Their values can be fetched from the INSERTED table.

Upvotes: 1

Related Questions