Skip to content

Commit 71620b2

Browse files
Merge pull request #51 from mlakatkou/GS-3266
GS-3266
2 parents 9c7a18c + 74a89a0 commit 71620b2

1 file changed

Lines changed: 29 additions & 33 deletions

File tree

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)