Skip to content

Commit 07e4fc8

Browse files
Merge pull request #70 from mlakatkou/GS-3310
[update] crud-task article
2 parents 6b5cd30 + e5a275a commit 07e4fc8

1 file changed

Lines changed: 37 additions & 39 deletions

File tree

docs/guides/crud-task.md

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,31 @@ sidebar_label: "Basic Operations with Tasks"
55

66
# Basic Operations with Tasks
77

8-
In this chapter you'll learn how to do basic operations with tasks: to create or delete a task, to dynamically update a task's property.
9-
8+
In this chapter, you'll learn how to perform basic operations with tasks: create or delete a task and dynamically update a task property.
109

1110
## Adding a new task
1211

13-
To add a new task to the Gantt chart, use the [addTask](api/method/addtask.md) method:
12+
To add a new task to the Gantt chart, use the [`addTask()`](api/method/addtask.md) method:
1413

1514
~~~js
16-
var taskId = gantt.addTask({
17-
id:10,
18-
text:"Project #1",
19-
start_date:"02-09-2020",
20-
duration:28
15+
const taskId = gantt.addTask({
16+
id: 10,
17+
text: "Project #1",
18+
start_date: "2027-09-02",
19+
duration: 28
2120
});
2221
~~~
2322

2423
### Preventing from adding tasks to certain levels
2524

26-
A quite easy way to prevent users from adding sub-tasks to a task of a certain level (or based on some other condition) is to hide the 'Add' button through CSS.
25+
A simple way to prevent users from adding subtasks to a task of a certain level, or based on some other condition, is to hide the 'Add' button through CSS.
2726

28-
You can assign a CSS class for each task row using the [grid_row_class](api/template/grid_row_class.md) template:
27+
You can assign a CSS class for each task row using the [`grid_row_class`](api/template/grid_row_class.md) template:
2928

3029
~~~js
31-
gantt.templates.grid_row_class = function( start, end, task ){
32-
if ( task.$level > 1 ){
33-
return "nested_task"
30+
gantt.templates.grid_row_class = (start, end, task) => {
31+
if (task.$level > 1) {
32+
return "nested_task";
3433
}
3534
return "";
3635
};
@@ -39,7 +38,7 @@ gantt.templates.grid_row_class = function( start, end, task ){
3938
and hide the 'Add' button for such rows:
4039

4140
~~~css
42-
.nested_task .gantt_add{
41+
.nested_task .gantt_add {
4342
display: none !important;
4443
}
4544
~~~
@@ -49,44 +48,44 @@ and hide the 'Add' button for such rows:
4948

5049
## Updating a task's property
5150

52-
To dynamically update a property of a task object, use the [updateTask](api/method/updatetask.md) method:
51+
To dynamically update a property of a task object, use the [`updateTask()`](api/method/updatetask.md) method:
5352

54-
~~~js
55-
var task = gantt.getTask(10);//->{id:10,text:"Task #10",start_date:"02-09-2020",...}
56-
57-
task.text = "Task #10_1";/*!*/
58-
gantt.updateTask(10); /*!*/
53+
~~~js {3-4}
54+
const task = gantt.getTask(10); // -> { id: 10, text: "Task #10", start_date: "2027-09-02", ... }
55+
56+
task.text = "Task #10_1";
57+
gantt.updateTask(10);
5958
~~~
6059

61-
If Data Processor is enabled, the [updateTask()](api/method/updatetask.md) method will cause the changes to be sent to the server.
60+
If Data Processor is enabled, the [`updateTask()`](api/method/updatetask.md) method will cause the changes to be sent to the server.
6261

63-
After the task is updated, the [onAfterTaskUpdate](api/event/onaftertaskupdate.md) event fires. It can cause other changes, for example, when the auto scheduling is enabled, Gantt will auto-schedule the task and all its successors.
62+
After the task is updated, the [`onAfterTaskUpdate`](api/event/onaftertaskupdate.md) event fires. It can cause other changes. For example, when auto scheduling is enabled, Gantt will auto-schedule the task and all its successors.
6463

65-
If you need just to re-render the changes, call the [refreshTask()](api/method/refreshtask.md) method instead of [updateTask()](api/method/updatetask.md).
64+
If you need just to re-render the changes, call the [`refreshTask()`](api/method/refreshtask.md) method instead of [`updateTask()`](api/method/updatetask.md).
6665

6766
~~~js
68-
var task = gantt.getTask(10);//->{id:10,text:"Task #10",start_date:"02-09-2020",...}
69-
70-
task.text = "Task #10_1";
67+
const task = gantt.getTask(10); // -> { id: 10, text: "Task #10", start_date: "2027-09-02", ... }
68+
69+
task.text = "Task #10_1";
7170
gantt.refreshTask(10);
7271
~~~
7372

7473
## Redrawing tasks
7574

76-
To re-draw all tasks in the Gantt chart, use the [refreshData](api/method/refreshdata.md) method:
75+
To redraw all tasks in the Gantt chart, use the [`refreshData()`](api/method/refreshdata.md) method:
7776

78-
~~~js
79-
var task = gantt.getTask(10);//->{id:10,text:"Task #10",start_date:"02-09-2020",...}
80-
var task2 = gantt.getTask(11);//->{id:11,text:"Task #11",start_date:"05-09-2020",...}
81-
82-
task.text = "Task #10_1"; /*!*/
83-
task2.text = "Task #11_1";/*!*/
84-
gantt.refreshData(); /*!*/
77+
~~~js {4-6}
78+
const firstTask = gantt.getTask(10); // -> { id: 10, text: "Task #10", start_date: "2027-09-02", ... }
79+
const secondTask = gantt.getTask(11); // -> { id: 11, text: "Task #11", start_date: "2027-09-05", ... }
80+
81+
firstTask.text = "Task #10_1";
82+
secondTask.text = "Task #11_1";
83+
gantt.refreshData();
8584
~~~
8685

8786
## Deleting tasks
8887

89-
To delete a task, use the [deleteTask](api/method/deletetask.md) method:
88+
To delete a task, use the [`deleteTask()`](api/method/deletetask.md) method:
9089

9190
~~~js
9291
gantt.deleteTask(taskId);
@@ -103,16 +102,15 @@ If you don't need to send multiple requests to the server, you can simply disabl
103102
gantt.config.cascade_delete = false;
104103
~~~
105104

106-
In that case Gantt will send only one request to the server - for deleting just the parent task, while its nested tasks and links will be deleted by the server.
105+
In that case, Gantt will send only one request to the server for deleting the parent task, while its nested tasks and links will be deleted by the server.
107106

108-
The [cascade_delete](api/config/cascade_delete.md) option affects the way of implemeting a backend. Read more in the
107+
The [cascade_delete](api/config/cascade_delete.md) option affects the way of implementing a backend. Read more in the
109108
[related section of the Server-side Integration article](guides/server-side.md#cascade-deletion).
110109

111110
## Removing all tasks from the Gantt chart
112111

113-
To clear the Gantt chart from tasks, call the [clearAll](api/method/clearall.md) method:
112+
To clear the Gantt chart from tasks, call the [`clearAll()`](api/method/clearall.md) method:
114113

115114
~~~js
116115
gantt.clearAll();
117116
~~~
118-

0 commit comments

Comments
 (0)