Search code examples
kendo-uikendo-scheduler

How to initialize kendo ui scheduler data model on create new


Kendo UI v2015.2.805

kendoScheduler

I implemented a event calendar using kendoScheduler and it is working fine except I cannot initialize the data model when a new event is being created.

I am using a custom template for the scheduler editor. Here is a simplified snippet:

<script type="text/x-kendo-template" id="schedulerTemplate">
    <div >Created by #= xCreatedBy #</div>
</script>

When editing an existing event the field xCreatedBy is populated from the database with the name of the person that created it.

Created By John Smith

To add a new task I double click a date on the calendar and the editor opens, but xCreatedBy is null so it displays:

Created By null

In the data source I define the data model and provide default values, like in this simplified example:

$("#task_calendar").kendoScheduler({
    dataSource: {
    ...CRUD operations....
    schema: {
        model: {
            id: "taskId",
            fields: {
                xCreatedBy: { from: "xCreatedBy", defaultValue: "Your_Name" }              }
        }
    }
});

I expected xCreatedBy to equal "Your_Name" but it is null.

How can I initialize the model when a new event is created (that is, not queried from the database)?


Solution

  • I have tested the described behavior and it worked correctly at my side. Here is my test dojo.