Skip to content

Commit 5491ae8

Browse files
author
Victory
committed
[add] docs for actions: deprecate events, add docs for migration article, update Actions overview
1 parent 7027c3f commit 5491ae8

30 files changed

+455
-13
lines changed

docs/api/api_overview.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Parameters:
5959

6060
| Name | Description |
6161
| :---------------------------------------------- | :----------------------------------------------------- |
62+
| [](api/spreadsheet_afteraction_event.md) | @getshort(api/spreadsheet_afteraction_event.md) |
6263
| [](api/spreadsheet_afterclear_event.md) | @getshort(api/spreadsheet_afterclear_event.md) |
6364
| [](api/spreadsheet_aftercolumnadd_event.md) | @getshort(api/spreadsheet_aftercolumnadd_event.md) |
6465
| [](api/spreadsheet_aftercolumndelete_event.md) | @getshort(api/spreadsheet_aftercolumndelete_event.md) |
@@ -76,6 +77,7 @@ Parameters:
7677
| [](api/spreadsheet_aftersheetrename_event.md) | @getshort(api/spreadsheet_aftersheetrename_event.md) |
7778
| [](api/spreadsheet_afterstylechange_event.md) | @getshort(api/spreadsheet_afterstylechange_event.md) |
7879
| [](api/spreadsheet_aftervaluechange_event.md) | @getshort(api/spreadsheet_aftervaluechange_event.md) |
80+
| [](api/spreadsheet_beforeaction_event.md) | @getshort(api/spreadsheet_beforeaction_event.md) |
7981
| [](api/spreadsheet_beforeclear_event.md) | @getshort(api/spreadsheet_beforeclear_event.md) |
8082
| [](api/spreadsheet_beforecolumnadd_event.md) | @getshort(api/spreadsheet_beforecolumnadd_event.md) |
8183
| [](api/spreadsheet_beforecolumndelete_event.md) | @getshort(api/spreadsheet_beforecolumndelete_event.md) |

docs/api/overview/actions_overview.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,50 @@ description: You can have an Actions overview of the DHTMLX JavaScript Spreadshe
66

77
# Actions overview
88

9-
From v4.3, you don't have to constantly add a set of paired **before-** and **after-** events to track and handle the actions which you execute when changing something in the spreadsheet.
9+
:::info
10+
From v4.3, the Spreadsheet library introduces a new conception of interaction with Spreadsheet events.
11+
:::
1012

11-
Now DHTMLX Spreadsheet includes a pair of the [beforeAction](api/spreadsheet_beforeaction_event.md)/[afterAction](api/spreadsheet_afteraction_event.md) events that are intended to make your code simple and concise. They will fire right before an action is executed and indicate which exactly action was performed.
13+
Now DHTMLX Spreadsheet includes a pair of the [beforeAction](api/spreadsheet_beforeaction_event.md)/[afterAction](api/spreadsheet_afteraction_event.md) events that are intended to make your code simple and concise. They will fire right before an action is executed and indicate which exactly action has been performed.
1214

13-
The full list of available actions is given below.
15+
~~~js
16+
spreadsheet.events.on("beforeAction", (actionName, config) => {
17+
if (actionName === "addColumn") {
18+
console.log(actionName, config);
19+
return false;
20+
},
21+
// more actions
22+
});
23+
24+
spreadsheet.events.on("afterAction", (actionName, config) => {
25+
if (actionName === "addColumn") {
26+
console.log(actionName, config)
27+
},
28+
// more actions
29+
});
30+
~~~
31+
32+
[The full list of the available actions is given below.](#list-of-actions)
33+
34+
>It means, that you don't have to constantly add sets of paired [**before-** and **after-**](api/overview/events_overview.md) events anymore to track and handle the actions which you execute when changing something in the spreadsheet.
35+
36+
>But if needed you can use an **old approach** because all the existing events will continue work as before:
37+
~~~js
38+
spreadsheet.events.on("afterColumnAdd", function(cell){
39+
console.log("A new column is added", cell);
40+
});
41+
~~~
42+
~~~js
43+
spreadsheet.events.on("beforeColumnAdd", function(cell){
44+
console.log("A new column will be added", cell);
45+
return true;
46+
});
47+
~~~
48+
49+
50+
51+
52+
## List of actions
1453

1554
| Action | Description |
1655
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -29,7 +68,9 @@ The full list of available actions is given below.
2968
| **resizeCol** | The action is executed when you resize a column |
3069
| **resizeRow** | The action is executed when you resize a row |
3170
| **setCellFormat** | The action is executed when you change the format of a cell |
32-
| **setCellValue** | The action is executed when you change the value of a cell |
71+
| **setCellValue** | The action is executed when you change or remove the value of a cell |
3372
| **setValidation** | The action is executed when you set data validation for a cell |
3473
| **sortCells** | The action is executed when you sort data in spreadsheet |
35-
| **setCellStyle** | The action is executed when you change the style of a cell |
74+
| **setCellStyle** | The action is executed when you change the style of a cell |
75+
76+
**Related sample:** [Spreadsheet. Actions](https://snippet.dhtmlx.com/efcuxlkt)

docs/api/overview/events_overview.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ description: You can have an Events overview of the DHTMLX JavaScript Spreadshee
66

77
# Events overview
88

9-
| Name | Description |
10-
| :---------------------------------------------- | :----------------------------------------------------- |
9+
| Name | Description |
10+
| :--------------------------------------------- | :---------------------------------------------------- |
11+
| [](../spreadsheet_afteraction_event.md) | @getshort(../spreadsheet_afteraction_event.md) |
1112
| [](../spreadsheet_afterclear_event.md) | @getshort(../spreadsheet_afterclear_event.md) |
1213
| [](../spreadsheet_aftercolumnadd_event.md) | @getshort(../spreadsheet_aftercolumnadd_event.md) |
1314
| [](../spreadsheet_aftercolumndelete_event.md) | @getshort(../spreadsheet_aftercolumndelete_event.md) |
@@ -25,6 +26,7 @@ description: You can have an Events overview of the DHTMLX JavaScript Spreadshee
2526
| [](../spreadsheet_aftersheetrename_event.md) | @getshort(../spreadsheet_aftersheetrename_event.md) |
2627
| [](../spreadsheet_afterstylechange_event.md) | @getshort(../spreadsheet_afterstylechange_event.md) |
2728
| [](../spreadsheet_aftervaluechange_event.md) | @getshort(../spreadsheet_aftervaluechange_event.md) |
29+
| [](../spreadsheet_beforeaction_event.md) | @getshort(../spreadsheet_beforeaction_event.md) |
2830
| [](../spreadsheet_beforeclear_event.md) | @getshort(../spreadsheet_beforeclear_event.md) |
2931
| [](../spreadsheet_beforecolumnadd_event.md) | @getshort(../spreadsheet_beforecolumnadd_event.md) |
3032
| [](../spreadsheet_beforecolumndelete_event.md) | @getshort(../spreadsheet_beforecolumndelete_event.md) |

docs/api/spreadsheet_afteraction_event.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ afterAction: (action: string, config: object) => void;
2020

2121
The callback of the event takes the following parameters:
2222

23-
- `action` - (required) the name of the action. Check the full list of available actions here
23+
- `action` - (required) the name of the action. Check the full list of available actions [here](api/overview/actions_overview.md#list-of-actions)
2424
- `config` - (required) an object with parameters of the action
2525

2626
### Example
@@ -31,9 +31,15 @@ const spreadsheet = new dhx.Spreadsheet("spreadsheet", {
3131
});
3232
spreadsheet.parse(dataset);
3333

34-
spreadsheet.events.on("AfterAction", (actionName, config) => {
34+
spreadsheet.events.on("afterAction", (actionName, config) => {
3535
if (actionName === "sortCells") {
3636
console.log(actionName, config);
3737
}
3838
});
39-
~~~
39+
~~~
40+
41+
**Changelog:** Added in v4.3
42+
43+
**Related articles:**
44+
- [Spreadsheet actions](api/overview/actions_overview.md)
45+
- [Event handling](handling_events.md)

docs/api/spreadsheet_afterclear_event.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ description: You can learn about the afterClear event in the documentation of th
66

77
# afterClear
88

9+
:::caution
10+
The **afterClear** event has been deprecated in v4.3. The event will continue work, but you'd better apply a new approach:
11+
12+
~~~js
13+
spreadsheet.events.on("afterAction", (actionName, config) => {
14+
if (actionName === "clear") {
15+
console.log(actionName, config);
16+
}
17+
});
18+
~~~
19+
20+
For more details about the new concept, see **[Spreadsheet actions](api/overview/actions_overview.md)**.
21+
:::
22+
923
### Description
1024

1125
@short: Fires after a spreadsheet is cleared

docs/api/spreadsheet_aftercolumnadd_event.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ description: You can learn about the afterColumnAdd event in the documentation o
66

77
# afterColumnAdd
88

9+
:::caution
10+
The **afterColumnAdd** event has been deprecated in v4.3. The event will continue work, but you'd better apply a new approach:
11+
12+
~~~js
13+
spreadsheet.events.on("afterAction", (actionName, config) => {
14+
if (actionName === "addColumn") {
15+
console.log(actionName, config)
16+
}
17+
});
18+
~~~
19+
20+
For more details about the new concept, see **[Spreadsheet actions](api/overview/actions_overview.md)**.
21+
:::
22+
923
### Description
1024

1125
@short: Fires after a new column is added

docs/api/spreadsheet_aftercolumndelete_event.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ description: You can learn about the afterColumnDelete event in the documentatio
66

77
# afterColumnDelete
88

9+
:::caution
10+
The **afterColumnDelete** event has been deprecated in v4.3. The event will continue work, but you'd better apply a new approach:
11+
12+
~~~js
13+
spreadsheet.events.on("afterAction", (actionName, config) => {
14+
if (actionName === "deleteColumn") {
15+
console.log(actionName, config)
16+
}
17+
});
18+
~~~
19+
20+
For more details about the new concept, see **[Spreadsheet actions](api/overview/actions_overview.md)**.
21+
:::
22+
923
### Description
1024

1125
@short: Fires after a column is deleted

docs/api/spreadsheet_afterformatchange_event.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ description: You can learn about the afterFormatChange event in the documentatio
66

77
# afterFormatChange
88

9+
:::caution
10+
The **afterFormatChange** event has been deprecated in v4.3. The event will continue work, but you'd better apply a new approach:
11+
12+
~~~js
13+
spreadsheet.events.on("afterAction", (actionName, config) => {
14+
if (actionName === "setCellFormat") {
15+
console.log(actionName, config);
16+
}
17+
});
18+
~~~
19+
20+
For more details about the new concept, see **[Spreadsheet actions](api/overview/actions_overview.md)**.
21+
:::
22+
923
### Description
1024

1125
@short: Fires after the format of a cell is changed

docs/api/spreadsheet_afterrowadd_event.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ description: You can learn about the afterRowAdd event in the documentation of t
66

77
# afterRowAdd
88

9+
:::caution
10+
The **afterRowAdd** event has been deprecated in v4.3. The event will continue work, but you'd better apply a new approach:
11+
12+
~~~js
13+
spreadsheet.events.on("afterAction", (actionName, config) => {
14+
if (actionName === "addRow") {
15+
console.log(actionName, config);
16+
}
17+
});
18+
~~~
19+
20+
For more details about the new concept, see **[Spreadsheet actions](api/overview/actions_overview.md)**.
21+
:::
22+
923
### Description
1024

1125
@short: Fires after a new row is added

docs/api/spreadsheet_afterrowdelete_event.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ description: You can learn about the afterRowDelete event in the documentation o
66

77
# afterRowDelete
88

9+
:::caution
10+
The **afterRowDelete** event has been deprecated in v4.3. The event will continue work, but you'd better apply a new approach:
11+
12+
~~~js
13+
spreadsheet.events.on("afterAction", (actionName, config) => {
14+
if (actionName === "deleteRow") {
15+
console.log(actionName, config);
16+
}
17+
});
18+
~~~
19+
20+
For more details about the new concept, see **[Spreadsheet actions](api/overview/actions_overview.md)**.
21+
:::
22+
923
### Description
1024

1125
@short: Fires after a row is deleted

0 commit comments

Comments
 (0)