Skip to content

Commit a78826f

Browse files
committed
Merge branch 'master' into next
# Conflicts: # sidebars.js
2 parents 3937a37 + 043920e commit a78826f

19 files changed

Lines changed: 403 additions & 375 deletions

docs/api/config/autosize.md

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,70 +24,69 @@ gantt.init("gantt_here");
2424

2525
### Details
2626

27-
The 'autosize' config defines whether the gantt will fit data inside the sizes of container where it's initialized showing inner scrollbars,
28-
or modify the sizes of container in order to show all data without inner scrolls:
27+
The `autosize` config defines whether the Gantt will fit data inside the size of the container where it's initialized and show inner scrollbars,
28+
or modify the size of the container in order to show all data without inner scrolls:
2929

30-
- [a sample with sizes of gantt div defined in css ](https://snippet.dhtmlx.com/5/b4d4d1b80) - inner scrollbars are active if necessary
31-
- [a sample with sizes of gantt div calculated by a component](https://snippet.dhtmlx.com/5/c278b3859) - inner scrollbars are disabled
30+
- [a sample with sizes of Gantt div defined in CSS](https://snippet.dhtmlx.com/2m48u5oz) - inner scrollbars are active if necessary
31+
- [a sample with sizes of Gantt div calculated by a component](https://snippet.dhtmlx.com/syzmiqwt) - inner scrollbars are disabled
3232

33-
In case gantt should fit a certain area on a page, the size of gantt container must be managed manually:
33+
In case Gantt should fit a certain area on a page, the size of the Gantt container must be managed manually:
3434

35-
- autosizing should be disabled
36-
- width/height of a div should be calculated either by html layout if some ready solution for responsive layouts is used, or manually by code.
35+
- autosizing should be disabled
36+
- width/height of a div should be calculated either by HTML layout if some ready solution for responsive layouts is used, or manually by code
3737

38-
## Scrolling to hidden elements
38+
## Scrolling to hidden elements
3939

40-
In the default mode, Gantt is scrolled automatically when you use the [showTask](api/method/showtask.md) or [showDate](api/method/showdate.md) method.
41-
But, when **autosize** is enabled, Gantt increases the size of its container to show itself on the page instead of showing the hidden element.
40+
In the default mode, Gantt is scrolled automatically when you use the [`showTask()`](api/method/showtask.md) or [`showDate()`](api/method/showdate.md) method.
41+
But, when `autosize` is enabled, Gantt increases the size of its container to show itself on the page instead of showing the hidden element.
4242

4343
There is no any universal way to escape the problem because the page can also include other elements except for Gantt, and some of the elements also need to be scrolled. Therefore, this problem should be solved depending on the page/application configuration.
4444

4545
In a *simple* configuration, Gantt may be located before or after some elements in your application. And it can work correctly if you scroll the page.
4646

47-
In a *complex* configuration, the Gantt container can be placed into other containers which can also be placed in some other containers.
48-
In this case, you need to manually scroll only the elements you need.
47+
In a *complex* configuration, the Gantt container can be placed into other containers which can also be placed in some other containers.
48+
In this case, you need to manually scroll only the elements you need.
4949

50-
One of the ways to make the page to be scrolled to the necessary element is use the **element.scrollIntoView** method:
50+
One of the ways to make the page scroll to the necessary element is to use the `element.scrollIntoView()` method:
5151

5252
~~~js
53-
var attr = gantt.config.task_attribute;
54-
var timelineElement = document.querySelector(".gantt_task_line["+attr+"='"+id+"']");
55-
if(timelineElement)
56-
timelineElement.scrollIntoView({block:"center"});
53+
const taskAttribute = gantt.config.task_attribute;
54+
const timelineElement = document.querySelector(`.gantt_task_line[${taskAttribute}='${id}']`);
55+
56+
timelineElement?.scrollIntoView({ block: "center" });
5757
~~~
5858

5959
where id is the task ID you need to show.
6060

61-
Another way is to modify the [showTask](api/method/showtask.md) or [showDate](api/method/showdate.md) method of Gantt:
61+
Another way is to modify the [`showTask()`](api/method/showtask.md) or [`showDate()`](api/method/showdate.md) method of Gantt:
6262

6363
~~~js
64-
var showTask = gantt.showTask;
65-
66-
gantt.showTask = function(id){
67-
showTask.apply(this, [id]);
68-
var attr = gantt.config.task_attribute;
69-
var timelineElement = document.querySelector(".gantt_task_line["+attr+"='"+id+"']");
70-
if(timelineElement)
71-
timelineElement.scrollIntoView({block:"center"});
64+
const defaultShowTask = gantt.showTask;
65+
66+
gantt.showTask = function(id) {
67+
defaultShowTask.apply(this, [id]);
68+
const taskAttribute = gantt.config.task_attribute;
69+
const timelineElement = document.querySelector(`.gantt_task_line[${taskAttribute}='${id}']`);
70+
71+
timelineElement?.scrollIntoView({ block: "center" });
7272
};
7373
~~~
7474

7575
or create a custom function to show the task:
7676

7777
~~~js
78-
function showTask(id){
79-
gantt.showTask(id);
80-
var attr = gantt.config.task_attribute;
81-
var timelineElement = document.querySelector(".gantt_task_line["+attr+"='"+id+"']");
82-
if(timelineElement)
83-
timelineElement.scrollIntoView({block:"center"});
84-
}
78+
const showTask = (id) => {
79+
gantt.showTask(id);
80+
const taskAttribute = gantt.config.task_attribute;
81+
const timelineElement = document.querySelector(`.gantt_task_line[${taskAttribute}='${id}']`);
82+
83+
timelineElement?.scrollIntoView({ block: "center" });
84+
};
8585
~~~
8686

8787
:::note
88-
sample: [Scrolling to the specified element](https://snippet.dhtmlx.com/or73u6a5)
88+
Sample: [Scrolling to the specified element](https://snippet.dhtmlx.com/or73u6a5)
8989
:::
9090

9191
### Related API
9292
- [autosize_min_width](api/config/autosize_min_width.md)
93-

docs/api/config/date_format.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,23 @@ gantt.load("/data/tasks");
2525

2626
### Details
2727

28-
This config value is used to generate [parse_date](api/template/parse_date.md) and [format_date](api/template/format_date.md) template functions.
29-
If you want to use a custom format, you can either change this config, or redefine **parse_date** and **format_date** templates directly.
28+
This config value is used to generate [`parse_date`](api/template/parse_date.md) and [`format_date`](api/template/format_date.md) template functions.
29+
If you want to use a custom format, you can either change this config, or redefine `parse_date` and `format_date` templates directly.
3030

3131
## Loading dates in ISO format
3232

33-
Since v9.1.3, Gantt automatically detects and parses ISO 8601 date strings. The `date_format` config is not needed for ISO strings - they are recognized and parsed directly.
33+
Since v9.1.3, Gantt automatically detects and parses ISO 8601 date strings. The `date_format` config is not needed for ISO strings - they are recognized and parsed directly.
3434

35-
When ISO dates are detected on input, they are serialized back as ISO strings automatically when passed to the [DataProcessor](guides/server-side.md). Date-only strings (e.g., `"2026-01-06"`) are serialized back as date-only strings, preserving the original format.
35+
When ISO dates are detected on input, they are serialized back as ISO strings automatically when passed to the [DataProcessor](api/method/dataprocessor.md). Date-only strings (e.g., `"2026-01-06"`) are serialized back as date-only strings, preserving the original format.
3636

3737
The `date_format` config still applies to non-ISO date strings.
3838

3939
:::tip Gantt v9.1.2 and earlier
4040
In versions before v9.1.3, ISO dates were not detected automatically. If you are using an older version, you need to override `parse_date` and `format_date` templates to handle ISO strings:
4141

4242
~~~js
43-
gantt.templates.parse_date = function(date) {
44-
return new Date(date);
45-
};
46-
gantt.templates.format_date = function(date) {
47-
return date.toISOString();
48-
};
43+
gantt.templates.parse_date = (date) => new Date(date);
44+
gantt.templates.format_date = (date) => date.toISOString();
4945
~~~
5046

5147
:::
@@ -54,15 +50,13 @@ For more details, see [Loading dates in ISO format](guides/loading.md#loading-da
5450

5551
## Changing the date format dynamically
5652

57-
If you need to change the date format dynamically, it is necessary to modify the [parse_date](api/template/parse_date.md) template in the following way:
53+
If you need to change the date format dynamically, it is necessary to modify the [`parse_date`](api/template/parse_date.md) template in the following way:
5854

5955
~~~js
60-
const cfg = gantt.config;
61-
const strToDate = gantt.date.str_to_date(cfg.date_format, cfg.server_utc);
56+
const config = gantt.config;
57+
const parseDate = gantt.date.str_to_date(config.date_format, config.server_utc);
6258

63-
gantt.templates.parse_date = function(date){
64-
return strToDate (date);
65-
};
59+
gantt.templates.parse_date = (date) => parseDate(date);
6660
~~~
6761

6862
### Related API
@@ -71,4 +65,3 @@ gantt.templates.parse_date = function(date){
7165

7266
### Related Guides
7367
- [Date Format Specification](guides/date-format.md)
74-

docs/api/method/attachevent.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ description: "attaches the handler to an inner event of dhtmlxGantt"
2424
### Example
2525

2626
~~~jsx
27-
gantt.attachEvent("onTaskClick", function(id, e) {
28-
alert("You've just clicked an item with id="+id);
27+
gantt.attachEvent("onTaskClick", (id, e) => {
28+
alert(`You've just clicked an item with id=${id}`);
2929
});
3030
~~~
3131

@@ -35,47 +35,46 @@ gantt.attachEvent("onTaskClick", function(id, e) {
3535
### Details
3636

3737
You can attach several handlers to the same event and all of them will be executed.
38-
If some of handlers will return *false* - the related operation will be blocked.
38+
If some of the handlers return *false*, the related operation will be blocked.
3939
Event handlers are processed in the same order that they were attached.
4040

41-
42-
## Properties of settings object
41+
## Properties of settings object
4342

4443
The settings object can contain the following properties:
4544

46-
- **id?** - (*string | number*) - the id of the event handler.
45+
- `id?` - (*string | number*) - the id of the event handler.
4746
For example, you can easily detach a handler from the specified event:
4847

49-
~~~js
50-
gantt.attachEvent("onTaskClick", function(){
48+
~~~js {3}
49+
gantt.attachEvent("onTaskClick", () => {
5150
console.log("task click");
52-
}, {id: "my-click"}); /*!*/
53-
... //after a while:
51+
}, { id: "my-click" });
52+
53+
// after a while
5454
gantt.detachEvent("my-click");
5555
~~~
5656

57-
- **once?** - (*boolean*) - defines whether the event will be executed only once.
57+
- `once?` - (*boolean*) - defines whether the event will be executed only once.
5858
Set the property to *true* if you want to capture the first triggering of the event, as in:
5959

60-
~~~js
61-
gantt.attachEvent("onTaskClick", function(){
60+
~~~js {4}
61+
gantt.attachEvent("onTaskClick", () => {
6262
console.log("capture next task click");
6363
return true;
64-
}, {once: true}); /*!*/
64+
}, { once: true });
6565
~~~
6666

67-
- **thisObject?** - (*any*) - specifies the `this` object for the listener.
67+
- `thisObject?` - (*any*) - specifies the `this` object for the listener.
6868

69-
~~~js
70-
gantt.attachEvent("onTaskClick", function(){
69+
~~~js {4}
70+
gantt.attachEvent("onTaskClick", function() {
7171
// ...
7272
return true;
73-
}, {thisObject: this}); /*!*/
73+
}, { thisObject: this });
7474
~~~
7575

7676
### Related API
7777
- [detachEvent](api/method/detachevent.md)
7878

7979
### Related Guides
8080
- [Event Handling](guides/handling-events.md)
81-

docs/api/method/updatetask.md

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,65 +20,62 @@ description: "updates the specified task"
2020
### Example
2121

2222
~~~jsx
23-
var taskId = gantt.addTask({
24-
id:10,
25-
text:"Task #10",
26-
start_date:"02-04-2013",
27-
duration:8,
28-
parent:1
23+
const taskId = gantt.addTask({
24+
id: 10,
25+
text: "Task #10",
26+
start_date: "2027-04-02",
27+
duration: 8,
28+
parent: 1
2929
});
3030

31-
gantt.getTask(taskId).text = "Task #13"; //changes task's data
32-
gantt.updateTask(taskId); //renders the updated task
31+
gantt.getTask(taskId).text = "Task #13"; // changes task data
32+
gantt.updateTask(taskId); // renders the updated task
3333
~~~
3434

3535
### Details
3636

3737
:::note
38-
The method invokes the [onAfterTaskUpdate](api/event/onaftertaskupdate.md) event.
38+
The method invokes the [`onAfterTaskUpdate`](api/event/onaftertaskupdate.md) event.
3939
:::
4040

4141
:::note
42-
The method triggers the [DataProcessor](guides/server-side.md) if the dataProcessor is enabled.
42+
The method triggers the [DataProcessor](api/method/dataprocessor.md) if the dataProcessor is enabled.
4343
:::
4444

4545
This method should be called after modifying the task object to update the Gantt's state, repaint related UI elements, and send the changes to the backend.
4646

47-
Calling this method will fire the [onAfterTaskUpdate](api/event/onaftertaskupdate.md) event, which may trigger additional recalculations.
47+
Calling this method will fire the [`onAfterTaskUpdate`](api/event/onaftertaskupdate.md) event, which may trigger additional recalculations.
4848

49-
If you're using the [DataProcessor](guides/server-side.md), invoking this method will prompt an **update** request to the server.
49+
If you're using the [DataProcessor](api/method/dataprocessor.md), invoking this method will prompt an **update** request to the server.
5050

51-
For making visual changes that don't require saving, **use the [refreshTask](api/method/refreshtask.md) method instead**. This will repaint the task without invoking extra calculations.
51+
For making visual changes that don't require saving, **use the [`refreshTask()`](api/method/refreshtask.md) method instead**. This will repaint the task without invoking extra calculations.
5252

53-
~~~js
54-
gantt.templates.task_class = function(start, end, task){
55-
if(task.$active) {
56-
return "active_task";
57-
}
58-
};
53+
~~~js {5}
54+
gantt.templates.task_class = (startDate, endDate, task) => task.$active ? "active_task" : "";
5955

60-
gantt.attachEvent("onTaskClick", function(id,e){
61-
gantt.getTask(id).$active = true;
62-
gantt.refreshTask(id); /*!*/
56+
gantt.attachEvent("onTaskClick", (taskId, event) => {
57+
gantt.getTask(taskId).$active = true;
58+
gantt.refreshTask(taskId);
6359
});
6460
~~~
6561

66-
67-
You can also replace the existing task with new values via setting a new task object as the second parameter of the **updateTask** method:
62+
You can also replace the existing task with new values by setting a new task object as the second parameter of the `updateTask()` method:
6863

6964
~~~js
70-
var task = {
71-
id: 2, text: 'New task text',
72-
start_date: new Date(2025,03,02),
73-
end_date: new Date(2025,03,04),
74-
$source: [1],
65+
const updatedTask = {
66+
id: 2,
67+
text: 'New task text',
68+
start_date: new Date(2025, 3, 2),
69+
end_date: new Date(2025, 3, 4),
70+
$source: [1],
7571
$target: [2]
76-
}
77-
gantt.updateTask(2,task);
72+
};
73+
74+
gantt.updateTask(2, updatedTask);
7875
~~~
7976

8077
:::note
81-
sample: [Updating task ](https://snippet.dhtmlx.com/fnfpoiik)
78+
Sample: [Updating task](https://snippet.dhtmlx.com/fnfpoiik)
8279
:::
8380

8481
### Related API
@@ -88,4 +85,3 @@ sample: [Updating task ](https://snippet.dhtmlx.com/fnfpoiik)
8885

8986
### Related Guides
9087
- [Server-Side Integration](guides/server-side.md)
91-

0 commit comments

Comments
 (0)