or
$(
"#scheduler"
).kendoScheduler({
date:
new
Date(
"2013/6/13"
),
startTime:
new
Date(
"2013/6/13 07:00 AM"
),
height: 600,
views: [
"day"
,
{ type:
"week"
, selected:
true
},
"month"
,
"agenda"
],
timezone:
"Etc/UTC"
,
save: scheduler_save,
remove: scheduler_remove,
edit: scheduler_edit,
cancel: scheduler_cancel,
dataSource: {
batch:
true
,
transport: {
read: {
url:
"/Team/Calendar/PopulateCalendar/"
,
dataType:
"json"
,
},
//update: {
// url: "/Team/Calendar/UpdateAppointment/",
// dataType: "json"
//},
//create: {
// url: "/Team/Calendar/CreateAppointment/",
// dataType: "json"
//},
//destroy: {
// dataType: "jsonp"
//},
parameterMap:
function
(options, operation) {
if
(operation !==
"read"
&& options.models) {
return
{ models: kendo.stringify(options.models) };
}
}
},
schema: {
model: {
id:
"taskId"
,
fields: {
taskId: { from:
"TaskID"
, type:
"number"
},
title: { from:
"Title"
, defaultValue:
"No title"
, validation: { required:
true
} },
start: { type:
"date"
, from:
"Start"
},
end: { type:
"date"
, from:
"End"
},
startTimezone: { from:
"StartTimezone"
},
endTimezone: { from:
"EndTimezone"
},
description: { from:
"Description"
},
recurrenceId: { from:
"RecurrenceID"
},
recurrenceRule: { from:
"RecurrenceRule"
},
recurrenceException: { from:
"RecurrenceException"
},
ownerId: { from:
"OwnerID"
, defaultValue: 1 },
isAllDay: { type:
"boolean"
, from:
"IsAllDay"
}
}
}
},
resources: [
{
field:
"ownerId"
,
title:
"Owner"
,
dataSource: [
{ text:
"Alex"
, value: 1, color:
"#f8a398"
},
{ text:
"Bob"
, value: 2, color:
"#51a0ed"
},
{ text:
"Charlie"
, value: 3, color:
"#56ca85"
}
]
}
]
}
})
});
var
grid = $(
"#saleGrid"
).data(
"kendoGrid"
);
row = grid.select();
item = grid.dataItem(row);
dataSource: {
batch: true,
transport: {
read: {
url: "/Team/Calendar/PopulateCalendar/",
dataType: "json",
},
update: {
url: "/Team/Calendar/UpdateAppointment",
dataType: "json"
},
create: {
url: "/Team/Calendar/CreateAppointment",
dataType: "jsonp"
},
destroy: {
dataType: "jsonp"
},
<script src=
"@Url.Content("
~/Scripts/jquery-1.7.1.min.js
")"
> </script>
<script src=
"@Url.Content("
~/Scripts/kendo/kendo.all.min.js
")"
></script>
<script>
$(
function
() {
$(
"#scheduler"
).kendoScheduler({
date:
new
Date(
"2013/6/13"
),
startTime:
new
Date(
"2013/6/13 07:00 AM"
),
height: 600,
views: [
"day"
,
{ type:
"week"
, selected:
true
},
"month"
,
"agenda"
],
timezone:
"Etc/UTC"
,
dataSource: {
batch:
true
,
transport: {
read: {
url:
"/Team/Calendar/PopulateCalendar/"
,
dataType:
"json"
,
},
update: {
dataType:
"jsonp"
},
create: {
dataType:
"jsonp"
},
destroy: {
dataType:
"jsonp"
},
parameterMap:
function
(options, operation) {
if
(operation !==
"read"
&& options.models) {
return
{ models: kendo.stringify(options.models) };
}
}
},
schema: {
model: {
id:
"taskId"
,
fields: {
taskId: { from:
"TaskID"
, type:
"number"
},
title: { from:
"Title"
, defaultValue:
"No title"
, validation: { required:
true
} },
start: { type:
"date"
, from:
"Start"
},
end: { type:
"date"
, from:
"End"
},
startTimezone: { from:
"StartTimezone"
},
endTimezone: { from:
"EndTimezone"
},
description: { from:
"Description"
},
recurrenceId: { from:
"RecurrenceID"
},
recurrenceRule: { from:
"RecurrenceRule"
},
recurrenceException: { from:
"RecurrenceException"
},
ownerId: { from:
"OwnerID"
, defaultValue: 1 },
isAllDay: { type:
"boolean"
, from:
"IsAllDay"
}
}
}
},
filter: {
logic:
"or"
,
filters: [
{ field:
"ownerId"
, operator:
"eq"
, value: 1 },
{ field:
"ownerId"
, operator:
"eq"
, value: 2 }
]
}
},
resources: [
{
field:
"ownerId"
,
title:
"Owner"
,
dataSource: [
{ text:
"Alex"
, value: 1, color:
"#f8a398"
},
{ text:
"Bob"
, value: 2, color:
"#51a0ed"
},
{ text:
"Charlie"
, value: 3, color:
"#56ca85"
}
]
}
]
});
$(
"#people :checkbox"
).change(
function
(e) {
var
checked = $.map($(
"#people :checked"
),
function
(checkbox) {
return
parseInt($(checkbox).val());
});
var
filter = {
logic:
"or"
,
filters: $.map(checked,
function
(value) {
return
{
operator:
"eq"
,
field:
"ownerId"
,
value: value
};
})
};
var
scheduler = $(
"#scheduler"
).data(
"kendoScheduler"
);
scheduler.dataSource.filter(filter);
});
});
</script>
public
ActionResult PopulateCalendar()
{
using
(var entities =
new
OpenRoad.Data.Repository.OpenRoadEntities())
{
var appointments = (from e
in
entities.Appointments
where e.UserId == OpenRoad.Web.Session.UserId
select
new
Models.Calendar
{
TaskID = e.AppointmentId,
UserId = e.UserId ??
'1'
,
Title = e.Subject,
Description=e.Description,
Start = e.StartTimeUtc ?? DateTime.Now,
End = e.EndTimeUtc ?? DateTime.Now,
IsAllDay =
false
,
RecurrenceRule=
null
,
RecurrenceID=
null
,
RecurrenceException=
null
,
StartTimezone=
null
,
EndTimezone=
null
,
}).OrderBy(o => o.Start).ToList();
return
Json(appointments, JsonRequestBehavior.AllowGet);
}
}
public
ActionResult PopulateCalendar()
{
using
(var entities =
new
OpenRoad.Data.Repository.OpenRoadEntities())
{
var appointments = (from e
in
entities.Appointments
where e.UserId == OpenRoad.Web.Session.UserId
select
new
Models.Calendar
{
TaskID = e.AppointmentId,
UserId = e.UserId ??
'1'
,
Title = e.Subject,
Description=e.Description,
Start = e.StartTimeUtc ?? DateTime.Now,
End = e.EndTimeUtc ?? DateTime.Now,
IsAllDay =
false
,
}).OrderBy(o => o.Start).ToList();
return
Json(appointments, JsonRequestBehavior.AllowGet);
}
}