I have the custom edit template working great for my scheduler. For updates of events, or creation of new events it works great after following all your examples.I am hung up on one item however. In my custom template i want to show a user name. This user name is populated in the model that is sent to the scheduler event. This works fine for when you modify events. however if i double click to create a brand new event, the model fields that are passed to the custom editor template are all empty. I can add an event to the scheduler to trap the "Add" event (which is what is called when double clicking to add a BRAND NEW event). But how do i send a filled-in model to that editor template?
FYI, using mvc5 with razor pages:
Here is the scheduler view page:
10 Answers, 1 is accepted
I wanted to add some more info: when you edit an existing scheduler event, the model is populated and is sent to the event template, and the owner name IS displayed at the top of the popup window. So, the field IS properly stored in the db, and is properly read via the Tasks_Read event.....and is properly sent to the "Tasks_Update" server side handlers.
It seems to me that when the Add event occurs, the client side code is just creating an empty model and sending that to the popup window.
In my use case, i always know the owner because they are the currently logged in user, so all events on a page will have same owner, so i would like to populate that info on the popup event window via the template and mvvm model params.
I am fearing that i may not have access to the kendo data object after it is constructed and sent to the popup view.
To achive the desired you could handle both the add and edit events. In the add event you set a flag, that the Scheduler enters in edit mode with a new event being created, while in the edit event you could populate the actual value of the owner.
Here you could find a simple demo, implementing the above.
Telerik by Progress
Thanks Vesselin, this approach works fine. I am wondering it is safe to use the TaskID being equal to 0 to indicate that the edit event is being called on a NEW task. This would be a shortcut to avoid having to override the Add event and set a flag.
The key issue to solve this problem was realizing the Add AND the Edit events are fired on a new task...and the add comes first, but the Edit event comes AFTER the model is initialized, so modifying the model inside the Edit event gives our code a crack at modifying the model fields prior to display. FYI, you can get access to the model data used by the scheduler with this magic:
You could safely avoid using the add handler, by checking the event object in the edit handler in the following way:
Thank you for the Model accessing logic, that you have shared.
Telerik by Progress
in the edit handler, the e.event object is of type kendo.data.SchedulerEvent. I understand that this is my scheduler model that i defined - so it has the fields in the class that i defined. But i couldn't find in the documentation all the "base methods" available to my event object. Methods such as isNew() that you use above. Where would i find that document for avialable methods in the base object?
I answered my own question:
kendo.data.model has the isNew() method.
i have small doubt here i also tried like this in MVC Razor syntax, but in your code i have small doubt can you explain me little bit more, because this complete line am not getting what your wrote here. and where i should i write this all <div> part. because i am first time using this Scheduler. so can you help me please.
.Editable( e => e.TemplateName( "SchedulerEditTemplate" ) )
<div class="k-edit-label"><label>Event Creator</label></div>
<div class="k-edit-field" >
<span data-bind="text: OwnerName"></span>
The Scheduler edit template should be defined in a separate view placed in the Views\Shared\EditorTemplates\ folder. In your case that view should be called "SchedulerEditTemplate.cshtml" and should contain the template definition: