Skip to content

Commit 44c0f13

Browse files
committed
[update] api pages for grid history module
1 parent 152562a commit 44c0f13

File tree

7 files changed

+148
-35
lines changed

7 files changed

+148
-35
lines changed

docs/grid/api/history/afterundo_event.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,20 @@ This functionality requires PRO version of the DHTMLX Grid (or DHTMLX Suite) pac
1212

1313
@short: triggered after successfully undoing an action
1414

15-
@signature: {'afterUndo: (action: IAction) => void;'}
15+
16+
### Usage
17+
18+
~~~jsx
19+
type ActionType = "add" | "remove" | "removeAll" | "change";
20+
21+
interface IAction {
22+
type: ActionType;
23+
batch: IRow[];
24+
inverse?: IAction;
25+
}
26+
27+
afterUndo: (action: IAction) => void;
28+
~~~
1629

1730
@params:
1831
The callback of the event is called with the following parameters:

docs/grid/api/history/beforeadd_event.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,32 @@ This functionality requires PRO version of the DHTMLX Grid (or DHTMLX Suite) pac
1212

1313
@short: triggered before adding an action to the history
1414

15-
@signature: {'beforeAdd: (action: IAction) => boolean | void;'}
15+
16+
### Usage
17+
18+
~~~jsx
19+
type ActionType = "add" | "remove" | "removeAll" | "change";
20+
21+
interface IAction {
22+
type: ActionType;
23+
batch: IRow[];
24+
inverse?: IAction;
25+
}
26+
27+
beforeAdd: (action: IAction) => boolean | void;
28+
~~~
1629

1730
@params:
1831
The callback of the event is called with the following parameters:
19-
- `action: IAction` - the action object to be added containing:
20-
- `type: ActionType` - the type of action: "add", "remove", "removeAll", or "change"
21-
- `batch: IRow[]` - an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)
22-
- `inverse?: IAction` - the inverse action required for undoing (for the "change" and "removeAll" types)
32+
33+
<table>
34+
<tbody>
35+
<tr>
36+
<td><b>action</b></td>
37+
<td>(<i>object</i>) the action object to be added that contains the following properties:<ul><li><b>`type`</b> - (<i>string</i>) the type of action: "add", "remove", "removeAll", or "change"</li><li><b>`batch`</b> - (<i>array</i>) an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)</li><li><b>`inverse`</b> - (<i>object</i>) optional, the inverse action required for undoing (mandatory for the "change" and "removeAll" types, not required for other types)</li></ul></td>
38+
</tr>
39+
</tbody>
40+
</table>
2341

2442
@returns:
2543
Returning `false` cancels the operation.

docs/grid/api/history/beforeredo_event.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,31 @@ This functionality requires PRO version of the DHTMLX Grid (or DHTMLX Suite) pac
1212

1313
@short: triggered before redoing an action
1414

15-
@signature: {'beforeRedo: (action: IAction) => boolean | void;'}
15+
### Usage
16+
17+
~~~jsx
18+
type ActionType = "add" | "remove" | "removeAll" | "change";
19+
20+
interface IAction {
21+
type: ActionType;
22+
batch: IRow[];
23+
inverse?: IAction;
24+
}
25+
26+
beforeRedo: (action: IAction) => boolean | void;
27+
~~~
1628

1729
@params:
1830
The callback of the event is called with the following parameters:
19-
- `action: IAction` - the action object from the redo stack containing:
20-
- `type: ActionType` - the type of action: "add", "remove", "removeAll", or "change"
21-
- `batch: IRow[]` - an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)
22-
- `inverse?: IAction` - the inverse action required for undoing (for the "change" and "removeAll" types)
31+
32+
<table>
33+
<tbody>
34+
<tr>
35+
<td><b>action</b></td>
36+
<td>(<i>object</i>) the action object from the redo stack that contains the following properties:<ul><li><b>`type`</b> - (<i>string</i>) the type of action: "add", "remove", "removeAll", or "change"</li><li><b>`batch`</b> - (<i>array</i>) an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)</li><li><b>`inverse`</b> - (<i>object</i>) optional, the inverse action required for undoing (mandatory for the "change" and "removeAll" types, not required for other types)</li></ul></td>
37+
</tr>
38+
</tbody>
39+
</table>
2340

2441
@returns:
2542
Returning `false` cancels the operation.

docs/grid/api/history/beforeundo_event.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,31 @@ This functionality requires PRO version of the DHTMLX Grid (or DHTMLX Suite) pac
1212

1313
@short: triggered before undoing an action
1414

15-
@signature: {'beforeUndo: (action: IAction) => boolean | void;'}
15+
### Usage
16+
17+
~~~jsx
18+
type ActionType = "add" | "remove" | "removeAll" | "change";
19+
20+
interface IAction {
21+
type: ActionType;
22+
batch: IRow[];
23+
inverse?: IAction;
24+
}
25+
26+
beforeUndo: (action: IAction) => boolean | void;
27+
~~~
1628

1729
@params:
1830
The callback of the event is called with the following parameters:
19-
- `action: IAction` - the action object containing:
20-
- `type: ActionType` - the type of action: "add", "remove", "removeAll", or "change"
21-
- `batch: IRow[]` - an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)
22-
- `inverse?: IAction` - the inverse action required for undoing (for the "change" and "removeAll" types)
31+
32+
<table>
33+
<tbody>
34+
<tr>
35+
<td><b>action</b></td>
36+
<td>(<i>object</i>) the action object that contains the following properties:<ul><li><b>`type`</b> - (<i>string</i>) the type of action: "add", "remove", "removeAll", or "change"</li><li><b>`batch`</b> - (<i>array</i>) an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)</li><li><b>`inverse`</b> - (<i>object</i>) optional, the inverse action required for undoing (mandatory for the "change" and "removeAll" types, not required for other types)</li></ul></td>
37+
</tr>
38+
</tbody>
39+
</table>
2340

2441
@returns:
2542
Returning `false` cancels the operation.

docs/grid/api/history/error_event.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,35 @@ This functionality requires PRO version of the DHTMLX Grid (or DHTMLX Suite) pac
1616
The event is triggered when an error occurs, such as the module is disabled, the history is empty, the action type is invalid, or the inverse action is missing for the `undo` operation.
1717
:::
1818

19-
@signature: {'error: (error: string, action: IAction | null) => void;'}
19+
### Usage
20+
21+
~~~jsx
22+
type ActionType = "add" | "remove" | "removeAll" | "change";
23+
24+
interface IAction {
25+
type: ActionType;
26+
batch: IRow[];
27+
inverse?: IAction;
28+
}
29+
30+
error: (error: string, action: IAction | null) => void;
31+
~~~
2032

2133
@params:
2234
The callback of the event is called with the following parameters:
23-
- `error` - the error message
24-
- `action: IAction` - the action object associated with the error, or `null`. The `action` object contains the following properties:
25-
- `type: ActionType` - the type of action: "add", "remove", "removeAll", or "change"
26-
- `batch: IRow[]` - an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)
27-
- `inverse?: IAction` - the inverse action required for undoing (for the "change" and "removeAll" types)
35+
36+
<table>
37+
<tbody>
38+
<tr>
39+
<td><b>error</b></td>
40+
<td>(<i>string</i>) the error message</td>
41+
</tr>
42+
<tr>
43+
<td><b>action</b></td>
44+
<td>(<i>object</i>) the action object associated with the error, or `null`. It contains the following properties:<ul><li><b>`type`</b> - (<i>string</i>) the type of action: "add", "remove", "removeAll", or "change"</li><li><b>`batch`</b> - (<i>array</i>) an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)</li><li><b>`inverse`</b> - (<i>object</i>) optional, the inverse action required for undoing (for the "change" and "removeAll" types)</li></ul></td>
45+
</tr>
46+
</tbody>
47+
</table>
2848

2949
@example:
3050
const grid = new dhx.Grid("grid_container", {

docs/grid/api/history/gethistory_method.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,31 @@ This functionality requires PRO version of the DHTMLX Grid (or DHTMLX Suite) pac
1212

1313
@short: returns a copy of the array of all actions in the Grid history to prevent accidental modification of the internal structure
1414

15-
@signature: {'getHistory(): IAction[];'}
15+
### Usage
16+
17+
~~~jsx
18+
type ActionType = "add" | "remove" | "removeAll" | "change";
19+
20+
interface IAction {
21+
type: ActionType;
22+
batch: IRow[];
23+
inverse?: IAction;
24+
}
25+
26+
getHistory(): IAction[];
27+
~~~
1628

1729
@returns:
18-
Returns a copy of the array of all actions in the history. Each `action` object may contain:
19-
- `type: ActionType` - the type of action: "add", "remove", "removeAll", or "change"
20-
- `batch: IRow[]` - an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)
21-
- `inverse?: IAction` - the inverse action required for undoing
30+
Returns a copy of the array of all actions in the Grid history, where each action presents an object described below:
31+
32+
<table>
33+
<tbody>
34+
<tr>
35+
<td><b>action</b></td>
36+
<td>(<i>object</i>) the action object that contains the following properties:<ul><li><b>`type`</b> - (<i>string</i>) the type of action: "add", "remove", "removeAll", or "change"</li><li><b>`batch`</b> - (<i>array</i>) an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)</li><li><b>`inverse`</b> - (<i>object</i>) optional, the inverse action required for undoing (for the "change" and "removeAll" types)</li></ul></td>
37+
</tr>
38+
</tbody>
39+
</table>
2240

2341
@example:
2442
// The example shows retrieving the history

docs/grid/usage_history.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,14 @@ For the "change" and "removeAll" actions, an `inverse` action is mandatory. Othe
140140

141141
You can add a new action into the history of actions within the grid by using the [`add()`](grid/api/history/add_method.md) method of the `history` object. The method takes the following parameters:
142142

143-
- `action: IAction` - the action object containing:
144-
- `type: ActionType` - the type of action: "add", "remove", "removeAll", or "change"
145-
- `batch: IRow[]` - an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)
146-
- `inverse?: IAction` - the inverse action required for undoing (mandatory for the "change" and "removeAll" types, not required for other types)
143+
<table>
144+
<tbody>
145+
<tr>
146+
<td><b>action</b></td>
147+
<td>(<i>object</i>) the action object that contains the following properties:<ul><li><b>`type`</b> - (<i>string</i>) the type of action: "add", "remove", "removeAll", or "change"</li><li><b>`batch`</b> - (<i>array</i>) an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)</li><li><b>`inverse`</b> - (<i>object</i>) optional, the inverse action required for undoing (mandatory for the "change" and "removeAll" types, not required for other types)</li></ul></td>
148+
</tr>
149+
</tbody>
150+
</table>
147151

148152
:::note
149153
The `action` argument must conform to the `IAction` interface. If the module is disabled, the action type is invalid, or the `inverse` property is missing (for actions with the "change" and "removeAll" types), the [`error`](grid/api/history/error_event.md) event is triggered.
@@ -397,10 +401,16 @@ To make the process of working with the undo/redo operations more flexible, you
397401

398402
You can get a copy of the array of all actions in the Grid history using the [`getHistory()`](grid/api/history/gethistory_method.md) method of the `history` object to prevent accidental modification of the internal structure.
399403

400-
Each `action` object in the returned array may contain the following properties:
401-
- `type: ActionType` - the type of action: "add", "remove", "removeAll", or "change"
402-
- `batch: IRow[]` - an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)
403-
- `inverse?: IAction` - the inverse action required for undoing (for the "change" and "removeAll" types)
404+
Each action in the returned array presents an object described below:
405+
406+
<table>
407+
<tbody>
408+
<tr>
409+
<td><b>action</b></td>
410+
<td>(<i>object</i>) the action object that contains the following properties:<ul><li><b>`type`</b> - (<i>string</i>) the type of action: "add", "remove", "removeAll", or "change"</li><li><b>`batch`</b> - (<i>array</i>) an array of rows representing the data affected by the action (e.g., added, removed, or modified rows)</li><li><b>`inverse`</b> - (<i>object</i>) optional, the inverse action required for undoing (for the "change" and "removeAll" types)</li></ul></td>
411+
</tr>
412+
</tbody>
413+
</table>
404414

405415
The example below shows retrieving the history:
406416

0 commit comments

Comments
 (0)