Files
2022-11-04 13:24:24 +02:00

289 lines
10 KiB
HTML
Executable File

<!DOCTYPE html>
<html>
<head>
<title>Templates</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>
<script src="../content/shared/js/ganttTasks.js"></script>
<div id="example">
<div id="gantt"></div>
<style type="text/css">
/*center treelist cell content vertically*/
.k-gantt .k-treelist td {
vertical-align: middle;
}
/*hide the resource labels, as they are present in the task template*/
.k-gantt .k-resource {
display: none;
}
/*style the task template*/
.k-task-template {
height: 100%;
padding: 0 !important;
}
.template {
height: 100%;
overflow: hidden;
}
.resource-img {
float: left;
width: 32px;
height: 32px;
border-radius: 50%;
margin: 8px;
}
.tree-list-img {
float: left;
width: 32px;
height: 32px;
border-radius: 50%;
}
.wrapper {
padding: 8px;
color: #fff;
}
.k-task-template .wrapper > * {
display: block;
overflow: hidden;
text-overflow: ellipsis;
}
.title {
font-weight: bold;
font-size: 13px;
}
.resource {
text-transform: uppercase;
font-size: 9px;
margin-top: .5em;
}
.progress {
position: absolute;
left: 0;
bottom: 0;
width: 0%;
height: 4px;
background: rgba(0, 0, 0, .3);
}
.team-lead-name {
display: inline-block;
vertical-align: middle;
line-height: 32px;
padding-left: 3px;
}
</style>
<script id="task-template" type="text/x-kendo-template">
# if (resources[0]) { #
<div class="template" style="background-color: #= resources[0].color #;">
<img class="resource-img" src="../content/web/gantt/resources/#:resources[0].id#.jpg" alt="#: resources[0].id #" />
<div class="wrapper">
<strong class="title">#= title # </strong>
<span class="resource">#= resources[0].name #</span>
</div>
<div class="progress" style="width:#= (100 * parseFloat(percentComplete)) #%"> </div>
</div>
# } else { #
<div class="template">
<div class="wrapper">
<strong class="title">#= title # </strong>
<span class="resource">no resource assigned</span>
</div>
<div class="progress" style="width:#= (100 * parseFloat(percentComplete)) #%"> </div>
</div>
# } #
</script>
<script id="column-template" type="text/x-kendo-template">
<img class="tree-list-img" src="../content/web/gantt/resources/#:teamLead#.jpg" alt="#: teamLead #" />
<span class="team-lead-name">#= teamLead #</span>
</script>
<script>
$(document).ready(function () {
var serviceRoot = "https://demos.telerik.com/kendo-ui/service";
var tasksDataSource = new kendo.data.GanttDataSource({
data: ganttTasks,
schema: {
model: {
id: "id",
fields: {
id: { from: "ID", type: "number" },
orderId: { from: "OrderID", type: "number", validation: { required: true } },
parentId: { from: "ParentID", type: "number", nullable: true, defaultValue: null, 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 },
teamLead: { from: "TeamLead", defaultValue: "", type: "string" },
}
}
}
});
var dependenciesDataSource = 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" }
}
}
}
});
var gantt = $("#gantt").kendoGantt({
dataSource: tasksDataSource,
dependencies: dependenciesDataSource,
resources: {
field: "resources",
dataColorField: "Color",
dataTextField: "Name",
dataSource: {
transport: {
read: {
url: serviceRoot + "/GanttResources",
dataType: "jsonp"
}
},
schema: {
model: {
id: "id",
fields: {
id: { from: "ID", type: "number" }
}
}
}
}
},
assignments: {
dataTaskIdField: "TaskID",
dataResourceIdField: "ResourceID",
dataValueField: "Units",
dataSource: {
transport: {
read: {
url: serviceRoot + "/GanttResourceAssignments",
dataType: "jsonp"
},
update: {
url: serviceRoot + "/GanttResourceAssignments/Update",
dataType: "jsonp"
},
destroy: {
url: serviceRoot + "/GanttResourceAssignments/Destroy",
dataType: "jsonp"
},
create: {
url: serviceRoot + "/GanttResourceAssignments/Create",
dataType: "jsonp"
},
parameterMap: function (options, operation) {
if (operation !== "read") {
return { models: kendo.stringify(options.models || [options]) };
}
}
},
schema: {
model: {
id: "ID",
fields: {
ID: { type: "number" },
ResourceID: { type: "number" },
Units: { type: "number" },
TaskID: { type: "number" }
}
}
}
}
},
views: [
"day",
{ type: "week", selected: true }
],
columns: [
{ field: "title", title: "Title", editable: true, sortable: true, width: 200 },
{ field: "resources", title: "Assigned Resources", editable: true },
{ field: "teamLead", title: "Team Lead", editable: false, template: $("#column-template").html() }
],
height: 700,
showWorkHours: false,
showWorkDays: false,
rowHeight: 62,
listWidth: "40%",
taskTemplate: $("#task-template").html(),
snap: false
}).data("kendoGantt");
$(document).bind("kendo:skinChange", function () {
gantt.refresh();
});
});
</script>
</div>
</body>
</html>