Skip to content

Commit 3b139bc

Browse files
Merge pull request #66 from mlakatkou/GS-3307
[update] start_date article
2 parents fcae97b + 1c2caed commit 3b139bc

1 file changed

Lines changed: 18 additions & 22 deletions

File tree

docs/api/config/start_date.md

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,37 @@ description: "sets the start value of the time scale"
1515
### Example
1616

1717
~~~jsx
18-
gantt.config.start_date = new Date(2018, 08, 10);
19-
gantt.config.end_date = new Date(2018, 08, 20);
20-
18+
gantt.config.start_date = new Date(2027, 8, 10);
19+
gantt.config.end_date = new Date(2027, 8, 20);
20+
2121
gantt.init("gantt_here");
2222
~~~
2323

2424
### Details
2525

2626
:::note
27-
To apply the **start_date** option, you must use it in pair with the [end_date](api/config/end_date.md) one.
27+
To apply the `start_date` option, you must use it together with [end_date](api/config/end_date.md).
2828
:::
2929

30-
- If both the **start_date** and **end_date** options are specified and you create a task that is outside the range, the task will disappear from the chart.
31-
- Optional parameters of the [init](api/method/init.md) method can be used as initial values of [start_date](api/config/start_date.md) and [end_date](api/config/end_date.md).
30+
- If both the [start_date](api/config/start_date.md) and [end_date](api/config/end_date.md) options are specified and you create a task outside that range, the task will disappear from the chart.
31+
- Optional parameters of [`init()`](api/method/init.md) can be used as initial values of [start_date](api/config/start_date.md) and [end_date](api/config/end_date.md).
3232
- [start_date](api/config/start_date.md) and [end_date](api/config/end_date.md) overwrite [fit_tasks](api/config/fit_tasks.md). If you want to use these settings together, you'll need to [manage the time scale from code](guides/configuring-time-scale.md#range).
3333

3434
In this case we can extend the range:
3535

3636
~~~js
37-
gantt.attachEvent("onLightboxSave", function(id, task, is_new){
38-
var taskStart = task.start_date;
39-
var taskEnd = task.end_date;
40-
var scaleStart = gantt.config.start_date;
41-
var scaleEnd = gantt.config.end_date;
42-
43-
// if the task is out of the range
44-
if(scaleStart > taskEnd || scaleEnd taskEnd || scaleEnd < taskStart ){
45-
gantt.message({
46-
type:"warning",
47-
text:"Warning! The task is outside the date range!",
48-
expire:5000
49-
});
50-
return false;
51-
}
37+
gantt.attachEvent("onLightboxSave", (taskId, task, isNew) => {
38+
const taskStartDate = task.start_date;
39+
const taskEndDate = task.end_date;
40+
const scaleStartDate = gantt.config.start_date;
41+
const scaleEndDate = gantt.config.end_date;
42+
43+
if (scaleStartDate > taskEndDate || scaleEndDate < taskStartDate) {
44+
gantt.message({ type: "warning", text: "Warning! The task is outside the date range!", expire: 5000 });
45+
46+
return false;
47+
}
48+
5249
return true;
5350
});
5451
~~~
@@ -61,4 +58,3 @@ gantt.attachEvent("onLightboxSave", function(id, task, is_new){
6158

6259
### Related Guides
6360
- [Setting up Scale](guides/configuring-time-scale.md)
64-

0 commit comments

Comments
 (0)