Files
jube-fork/Jube.App/wwwroot/kendo/examples/gantt/mvvm.html
2022-11-04 13:24:24 +02:00

180 lines
7.4 KiB
HTML
Executable File

<!DOCTYPE html>
<html>
<head>
<title>MVVM</title>
<meta charset="utf-8">
<link href="../content/shared/styles/examples-offline.css" rel="stylesheet">
<link href="../../styles/kendo.common.min.css" rel="stylesheet">
<link href="../../styles/kendo.rtl.min.css" rel="stylesheet">
<link href="../../styles/kendo.default.min.css" rel="stylesheet">
<link href="../../styles/kendo.default.mobile.min.css" rel="stylesheet">
<script src="../../js/jquery.min.js"></script>
<script src="../../js/jszip.min.js"></script>
<script src="../../js/kendo.all.min.js"></script>
<script src="../content/shared/js/console.js"></script>
<script>
</script>
</head>
<body>
<a class="offline-button" href="../index.html">Back</a>
<div id="example">
<div class="configurator">
<div class="header">Configurator</div>
<div class="box-col">
<h4>Configuration</h4>
<div>
<label>
<input type="checkbox" data-bind="checked: isVisible">Visible
</label>
</div>
</div>
<div class="box-col">
<h4>Information</h4>
Kendo UI Gantt supports the
<a href="https://docs.telerik.com/kendo-ui/getting-started/framework/mvvm/bindings/events">events</a>,
<a href="https://docs.telerik.com/kendo-ui/getting-started/framework/mvvm/bindings/source">source</a> and
<a href="https://docs.telerik.com/kendo-ui/getting-started/framework/mvvm/bindings/visible">visible</a> bindings,
<br>
as well as a source binding for dependencies.
</div>
</div>
<div class="demo-section k-content wide">
<h4>Add or update a record</h4>
<div data-role="gantt"
data-columns="[
{ field: 'id', title: 'ID', width: 60 },
{ field: 'title', title: 'Title', editable: true },
{ field: 'start', title: 'Start Time', format: '{0:MM/dd/yyyy}', width: 100 },
{ field: 'end', title: 'End Time', format: '{0:MM/dd/yyyy}', width: 100 }
]"
data-views="[ 'day', { type: 'week', selected: true }, 'month' ]"
data-show-work-hours="false"
data-show-work-days="false"
data-height="500"
data-bind="source: tasks,
dependencies: dependencies,
visible: isVisible,
events: {
save: onSave
}">
</div>
</div>
<script>
var serviceRoot = "https://demos.telerik.com/kendo-ui/service";
var viewModel = kendo.observable({
isVisible: true,
onSave: function (e) {
kendoConsole.log(
"Task saved :: " + e.task.title
);
},
tasks: new kendo.data.GanttDataSource({
transport: {
read: {
url: serviceRoot + "/GanttTasks",
dataType: "jsonp"
},
update: {
url: serviceRoot + "/GanttTasks/Update",
dataType: "jsonp",
timeout: 5000
},
destroy: {
url: serviceRoot + "/GanttTasks/Destroy",
dataType: "jsonp",
timeout: 5000
},
create: {
url: serviceRoot + "/GanttTasks/Create",
dataType: "jsonp",
timeout: 5000
},
parameterMap: function (options, operation) {
if (operation !== "read") {
return { models: kendo.stringify(options.models || [options]) };
}
}
},
schema: {
model: {
id: "id",
fields: {
id: { from: "ID", type: "number" },
orderId: { from: "OrderID", type: "number", validation: { required: true } },
parentId: { from: "ParentID", type: "number", defaultValue: null, nullable: true, validation: { required: true } },
start: { from: "Start", type: "date" },
end: { from: "End", type: "date" },
title: { from: "Title", defaultValue: "", type: "string" },
percentComplete: { from: "PercentComplete", type: "number" },
summary: { from: "Summary", type: "boolean" },
expanded: { from: "Expanded", type: "boolean", defaultValue: true }
}
}
},
error: function (ev) {
ev.sender.cancelChanges();
kendo.alert("Task was not Created, Updated or Destroyed properly!</br></br>" +
"If you are using this service for local demo or in dojo consider <a href='https://github.com/telerik/kendo-ui-demos-service/tree/master/demos-and-odata-v3'>downloading and running the service locally</a>.</br>" +
"And make sure to set the <a href='https://github.com/telerik/kendo-ui-demos-service/blob/master/demos-and-odata-v3/KendoCRUDService/Models/Gantt/GanttTaskRepository.cs#L12'>UpdateDatabase</a> flag to true.");
}
}),
dependencies: new kendo.data.GanttDependencyDataSource({
transport: {
read: {
url: serviceRoot + "/GanttDependencies",
dataType: "jsonp"
},
update: {
url: serviceRoot + "/GanttDependencies/Update",
dataType: "jsonp"
},
destroy: {
url: serviceRoot + "/GanttDependencies/Destroy",
dataType: "jsonp"
},
create: {
url: serviceRoot + "/GanttDependencies/Create",
dataType: "jsonp"
},
parameterMap: function (options, operation) {
if (operation !== "read") {
return { models: kendo.stringify(options.models || [options]) };
}
}
},
schema: {
model: {
id: "id",
fields: {
id: { from: "ID", type: "number" },
predecessorId: { from: "PredecessorID", type: "number" },
successorId: { from: "SuccessorID", type: "number" },
type: { from: "Type", type: "number" }
}
}
}
})
});
kendo.bind($("#example"), viewModel);
$(document).bind("kendo:skinChange", function () {
$("#example div[data-role='gantt']").data("kendoGantt").refresh();
});
</script>
</div>
</body>
</html>