I'm using the scheduler for only all-day items, and would like to sort items based off a given field (in this case a C# long value).
How would I go about doing this?
This is my current code:
@{
ViewBag.Title = $
"Profile Calendar"
;
}
<style>
/* increase the height of the cells in day, work week and week views */
.k-scheduler-table td,
.k-scheduler-table th {
height: 1em;
}
/* The following styles will work only with Kendo UI versions before 2020 R1 */
/* increase the height of the month view cells */
.k-scheduler-monthview .k-scheduler-table td {
height: 20em;
}
.k-event-template {
font-size: 0.75em;
width: 125px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
<h2>@ViewBag.Title</h2>
<div id=
"scheduler"
></div>
<script>
$(
function
() {
$(
"#scheduler"
).kendoScheduler({
change:
function
(e) {
var
start = e.start;
var
end = e.end;
console.log(kendo.format(
"Selection between {0:g} and {1:g}"
, start, end));
},
edit:
function
(e) {
e.preventDefault(
true
);
window.location.href =
"@Url.Action("
View
", "
Profile
")?id="
+ e.event.ProfileId;
},
views: [
{ type:
"month"
, selected:
true
},
{ type:
"day"
},
],
resources: [{
dataSource: {
transport: {
read: {
url:
"@Url.Action("
ListAll
", "
Lab
")"
}
},
schema: {
model: {
id:
"Id"
,
fields: {
Id: {
"type"
:
"number"
},
ProfileId: {
"type"
:
"number"
},
Name: {
"type"
:
"string"
},
DisplayColor: {
"type"
:
"string"
}
}
}
}
},
title:
"Lab"
,
field:
"LabId"
,
dataTextField:
"Name"
,
dataValueField:
"Id"
,
dataColorField:
"DisplayColor"
}],
dataSource: {
transport: {
read: {
url:
"@Url.Action("
List
", "
Calendar
")"
,
dataType:
"json"
,
contentType:
"application/json; charset=utf-8"
,
type:
"POST"
},
parameterMap:
function
(options, operation) {
if
(operation ===
"read"
) {
var
scheduler = $(
"#scheduler"
).data(
"kendoScheduler"
);
var
result = {
start: scheduler.view().startDate(),
end: scheduler.view().endDate()
}
return
kendo.stringify(result);
}
return
kendo.stringify(options);
}
},
serverFiltering:
true
,
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"
},
LabId: { from:
"LabId"
, type:
"number"
},
ProfileId: { from:
"ProfileId"
, type:
"number"
}
}
}
}
}
});
});
</script>
The field I want to sort by is LabId, which is a long.
Additionally, if there was a way to do this in MVC instead, greatly appreciated. With the inclusions of resources, I had trouble doing it in MVC.