Skip to content

Commit 28bc0b6

Browse files
author
Kendo Bot
committed
Sync with Kendo UI Professional
1 parent 6db5b5d commit 28bc0b6

File tree

6 files changed

+1616
-1475
lines changed

6 files changed

+1616
-1475
lines changed

docs/api/javascript/date.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ One (`1`) indicates the day after the current one (default value). Minus one (`-
7575

7676
### weekInYear
7777

78-
Returns week number of a specific date. According to the ISO-8601 standard, weeks starting on Monday.
78+
Returns week number of a specific date. According to the ISO-8601 standard, weeks starting on Monday.
7979
The first week of the year is the week that contains that year's first Thursday (='First 4-day week').
80-
The method allows defining diffent start day by using the second parameter.
80+
The method allows defining diffent start day by using the second parameter.
8181

8282
#### Parameters
8383

@@ -87,7 +87,7 @@ The given date.
8787

8888
##### weekStart `Number` *(optional)*
8989

90-
The day number (from 0 (Sunday) to 6 (Saturday)) representing what day of week is considered as a starting point. This parameter is optional because by default Monday (1) is considered as a first day of the week.
90+
The day number (from 0 (Sunday) to 6 (Saturday)) representing what day of week is considered as a starting point. This parameter is optional because by default Monday (1) is considered as a first day of the week.
9191

9292
#### Returns
9393

@@ -96,7 +96,7 @@ The day number (from 0 (Sunday) to 6 (Saturday)) representing what day of week i
9696
#### Example
9797
<script>
9898
//no weekStart is passed so Monday will be considered as starting point for week
99-
console.log(kendo.date.weekInYear(new Date(2017, 0, 9))); // 2
99+
console.log(kendo.date.weekInYear(new Date(2017, 0, 9))); // 2
100100
//Sunday is passed as week start
101101
console.log(kendo.date.weekInYear(new Date(2017, 0, 9), new Date(2017, 0, 8))); // 3
102102
</script>
@@ -458,7 +458,7 @@ The date object to get the milliseconds of.
458458

459459
#### Returns
460460

461-
`Date` Returns the milliseconds of a date object.
461+
`Number` Returns the milliseconds of a date object.
462462

463463
#### Example
464464

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
title: Add a Custom Time Marker in Gantt
3+
description: An example on how to add a vertical line similar to Current Time Marker in Kendo UI Gantt.
4+
type: how-to
5+
page_title: Add Custom Time Marker | Kendo UI Gantt
6+
slug: gantt-custom-time-marker
7+
tags: kendo, kendoui, gantt, custom, time, marker, primavera, status
8+
ticketid: 1343465
9+
res_type: kb
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tr>
16+
<td>Product</td>
17+
<td>Progress Kendo UI Gantt</td>
18+
</tr>
19+
</table>
20+
21+
22+
## Description
23+
24+
How can I add a custom Time Marker at a specific time similar to the built-in Current Time Marker of my Gantt?
25+
26+
## Solution
27+
28+
1. Add the `renderLine` function
29+
1. In the dataBound event of the Gantt call the function with the desired options.
30+
1. Add CSS styles using the class for the line or style the line element returned by the function.
31+
32+
```html
33+
<style>
34+
.k-gantt .k-status-time {
35+
background-color: blue;
36+
position: absolute;
37+
}
38+
</style>
39+
<div id="gantt"></div>
40+
<script>
41+
//https://stackoverflow.com/a/563442
42+
// implement addDays method for demonstration purposes
43+
Date.prototype.addDays = function (days) {
44+
var date = new Date(this.valueOf());
45+
date.setDate(date.getDate() + days);
46+
return date;
47+
}
48+
49+
Date.prototype.addHours = function (hours) {
50+
var date = new Date(this.valueOf());
51+
date.setHours(date.getHours() + hours);
52+
return date;
53+
}
54+
55+
$("#gantt").kendoGantt({
56+
dataSource: [
57+
{
58+
id: 1,
59+
orderId: 0,
60+
title: "Task1",
61+
start: new Date().addHours(2),
62+
end: new Date().addDays(1)
63+
},
64+
{
65+
id: 2,
66+
orderId: 1,
67+
title: "Task2",
68+
start: new Date().addHours(2),
69+
end: new Date().addDays(1)
70+
}
71+
],
72+
dataBound: function (e) {
73+
var statusLineDate = new Date().addHours(1);
74+
var $lineElement = renderLine(e.sender, statusLineDate);
75+
},
76+
dependencies: [
77+
{
78+
id: 1,
79+
predecessorId: 1,
80+
successorId: 2,
81+
type: 1
82+
}
83+
]
84+
});
85+
86+
function renderLine(gantt, date, lineClass) {
87+
var ganttView = gantt.view();
88+
lineClass = lineClass || "k-status-time"
89+
var currentTime = date;
90+
var timeOffset = ganttView._offset(currentTime);
91+
var element = $('<div class=\'' + lineClass + '\'></div>');
92+
var viewStyles = kendo.ui.GanttView.styles;
93+
var tablesWrap = $("." + viewStyles.tasksWrapper);
94+
var tasksTable = $("." + viewStyles.tasksTable);
95+
var slot;
96+
if (!ganttView.content || !ganttView._timeSlots().length) {
97+
return;
98+
}
99+
ganttView.content.find('.' + lineClass).remove();
100+
slot = ganttView._timeSlots()[ganttView._slotIndex('start', currentTime)];
101+
if (currentTime < slot.start || currentTime > slot.end) {
102+
return;
103+
}
104+
if (tablesWrap.length && tasksTable.length) {
105+
timeOffset += tasksTable.offset().left - tablesWrap.offset().left;
106+
}
107+
element.css({
108+
left: timeOffset + 'px',
109+
top: '0px',
110+
width: '1px',
111+
height: ganttView._contentHeight + 'px'
112+
}).appendTo(ganttView.content);
113+
114+
return element;
115+
}
116+
</script>
117+
```

0 commit comments

Comments
 (0)