This is a migrated thread and some comments may be shown as answers.

Update model values on click of task

1 Answer 117 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Sage
Top achievements
Rank 1
Sage asked on 15 Apr 2014, 06:25 PM

So I'm pretty new to using this component, so I'm not very familiar with it yet.

Here's what I'm trying to do:

I have a scheduler that I'm pre-populating with a lot of tasks.  I don't want the user to be able to add, delete, or update anything.  However, on selecting or clicking (or double clicking, whatever works best) I want to be able to update some other value in the model that was passed into the view.

For example: When user clicks on a task at 12:00 PM I don't want to show any pop ups or anything, but I want to set Model.appontmentTime equal to the tasks start time (i.e. 12:00 PM).

Also, as a side issue, for some reason when I attach a task to an owner as listed in the resources, the task is not showing in the right color.  Am I doing something wrong there?

So Far I have:

01.@(Html.Kendo().Scheduler<Humana.RetailSales.CGX.Site.TaskViewModel>()
02.            .Name("timeSlots")
03.            .Views(views => { views.WeekView(); })
04.            .Height(300)
05.            .Date(Model.appointmentCalendarRenderStartDate)
06.            .Height(400)
07.            .AllDaySlot(false)
08.            .MajorTick((int)Model.timeSlotInterval.TotalMinutes)
09.            .MinorTickCount(1)
10.            .Min(Model.appointmentCalendarRenderStartDate)
11.            .Max(Model.appointmentCalendarRenderFinishDate)
12.            .Resources(resource =>
13.            {
14.                resource.Add(m=> m.OwnerID)
15.                    .Title("Owner")
16.                    .DataTextField("Text")
17.                    .DataValueField("Value")
18.                    .DataColorField("Color")
19.                    .BindTo(new[] {
20.                        new { Text = "Many", Value = 1, color = "#003300"},
21.                        new { Text = "Few", Value = 2, color = "#CC3300"}
22.                    });
23.            })
24.            .DataSource(d => d
25.                .Model(m => {
26.                    m.Id(f => f.TaskID);
27.                    m.Field(f => f.Title).DefaultValue("No title");
28.                    m.Field(f => f.OwnerID).DefaultValue(1);
29.                    m.Field(f => f.Title).DefaultValue("No title");
30.                    m.RecurrenceId(f => f.RecurrenceID);
31.                })
32.
33.            )

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 17 Apr 2014, 01:57 PM
Hi Sage,

Please find the answers of your questions below:

1) On selecting or clicking (or double clicking, whatever works best) I want to be able to update some other value in the model that was passed into the view - Basically updating the ViewModel after the View initialization would not be possible without refreshing the page, however if you need to execute custom code on double-click on the Scheduler you can achieve that behavior as demonstrated below:

$(function () {
    //place the code after scheduler initialization:
    var scheduler = $("#scheduler").data("kendoScheduler");
    scheduler.element.bind("dblclick", ".k-scheduler-content td", function (e) {
        var slot = scheduler.slotByElement(e.target);
        alert("Clicked slot start time is: " + slot.startDate + " and end time is: " + slot.endDate );
    })
})

2) the task is not showing in the right color - the reason for current behavior is that the "Color" field in the data for the resources is typed with lower letter. After fixing it the colors will be rendered as expected:

.BindTo(new[] { new { Text = "Many", Value = 1, Color = "#003300"},

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Scheduler
Asked by
Sage
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or