Hi,I have a problem with data binding using a custom template for the editor for the Scheduler component.When double clicking an item in the scheduler my dialog is displayed, for for some reason, I am only able to databind against the properties of the ISchedulerEvent interface and not all the other properties of my ViewModel.ViewModel
Example:
public class MyViewModel : ISchedulerEvent
{
buplic int MyId { get; set;}
public bool MyBool{ get; set;}
public string MyString { get; set; }
#region ISchedulerEvent
public string Title { get; set; }
public string Description { get; set; }
public bool IsAllDay { get; set; }
public DateTime Start {get;set;}
public DateTime End { get; set; }
public string StartTimezone { get; set; }
public string EndTimezone { get; set; }
public string RecurrenceRule { get; set; }
public string RecurrenceException { get; set; }
#endregion
}
-----------
View Example:
@(Html.Kendo().Scheduler<MyViewModel>()
.Name("MyScheduler")
.Date(DateTime.Today)
.StartTime(DateTime.Today)
.EndTime(DateTime.Today.AddYears(1))
.Views(views =>
{
views.DayView();
views.WeekView(weekView => weekView.Selected(true));
views.MonthView();
})
.DataSource(d =>
{
d.Read(read => read.Url("/MyController/MyRead"));
d.Update(update => update.Url("/MyController/MyUpdate"));
d.Create(create => create.Url("/MyController/MyCreate"));
d.Destroy(destroy => destroy.Url("/MyController/MyDelete"));
d.Model(model =>
{
model.Id(f => f.MyId);
});
})
.BindTo(new [] {
new ServiceWindowViewModel{
MyId = 1,
MyBool = true,
MyString = "Yay this is my string",
Title = "title not used",
Description = "description not used",
End = DateTime.Now.AddHours(2),
EndTimezone = null,
IsAllDay = false,
RecurrenceException = null,
RecurrenceRule = null,
Start = DateTime.Now,
StartTimezone = null
}
})
.Editable(editable => {
editable.Confirmation(true);
editable.Create(true);
editable.Destroy(true);
editable.Resize(true);
editable.Update(true);
editable.TemplateId("editor");
})
)<script id="editor" type="text/x-kendo-template">
<div class="k-edit-label"><label for="title">Title</label></div>
<div class="k-edit-field" data-container-for="title"><input type="text" class="k-input k-textbox" name="title" data-bind="value: title"></div>
<BR>
<div class="k-edit-label"><label for="mystring">My String</label></div>
<div class="k-edit-field" data-container-for="mystring"><input type="text" class="k-input k-textbox" name="mystring" data-bind="value: mystring"></div>
</script>
-----------
Now My String editor box is displayed correctly... but the data is not displayed from the property of the view model... what am I doing wrong?Is there some other way to configure a custom edit popup for the Scheduler item? E.g. the editor for the grid seem to work better and is able to display all properties of my ViewModel correctly.Thanks,
Michael
Example:
public class MyViewModel : ISchedulerEvent
{
buplic int MyId { get; set;}
public bool MyBool{ get; set;}
public string MyString { get; set; }
#region ISchedulerEvent
public string Title { get; set; }
public string Description { get; set; }
public bool IsAllDay { get; set; }
public DateTime Start {get;set;}
public DateTime End { get; set; }
public string StartTimezone { get; set; }
public string EndTimezone { get; set; }
public string RecurrenceRule { get; set; }
public string RecurrenceException { get; set; }
#endregion
}
-----------
View Example:
@(Html.Kendo().Scheduler<MyViewModel>()
.Name("MyScheduler")
.Date(DateTime.Today)
.StartTime(DateTime.Today)
.EndTime(DateTime.Today.AddYears(1))
.Views(views =>
{
views.DayView();
views.WeekView(weekView => weekView.Selected(true));
views.MonthView();
})
.DataSource(d =>
{
d.Read(read => read.Url("/MyController/MyRead"));
d.Update(update => update.Url("/MyController/MyUpdate"));
d.Create(create => create.Url("/MyController/MyCreate"));
d.Destroy(destroy => destroy.Url("/MyController/MyDelete"));
d.Model(model =>
{
model.Id(f => f.MyId);
});
})
.BindTo(new [] {
new ServiceWindowViewModel{
MyId = 1,
MyBool = true,
MyString = "Yay this is my string",
Title = "title not used",
Description = "description not used",
End = DateTime.Now.AddHours(2),
EndTimezone = null,
IsAllDay = false,
RecurrenceException = null,
RecurrenceRule = null,
Start = DateTime.Now,
StartTimezone = null
}
})
.Editable(editable => {
editable.Confirmation(true);
editable.Create(true);
editable.Destroy(true);
editable.Resize(true);
editable.Update(true);
editable.TemplateId("editor");
})
)<script id="editor" type="text/x-kendo-template">
<div class="k-edit-label"><label for="title">Title</label></div>
<div class="k-edit-field" data-container-for="title"><input type="text" class="k-input k-textbox" name="title" data-bind="value: title"></div>
<BR>
<div class="k-edit-label"><label for="mystring">My String</label></div>
<div class="k-edit-field" data-container-for="mystring"><input type="text" class="k-input k-textbox" name="mystring" data-bind="value: mystring"></div>
</script>
-----------
Now My String editor box is displayed correctly... but the data is not displayed from the property of the view model... what am I doing wrong?Is there some other way to configure a custom edit popup for the Scheduler item? E.g. the editor for the grid seem to work better and is able to display all properties of my ViewModel correctly.Thanks,
Michael