Skip to content

Commit 64433dd

Browse files
committed
[update] data/treecollection api descriptions
1 parent 9ef717a commit 64433dd

7 files changed

Lines changed: 21 additions & 16 deletions

docs/data_collection/api/datacollection_add_method.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ description: You can explore the add method of DataCollection in the documentati
1212
Please note that data should be loaded into DataCollection via the `parse()` method. The `add()` method is primarily intended for loading standalone elements or small groups of elements, so its loads data slower than the `parse()` method.
1313
:::
1414

15-
### Usage
15+
#### Usage
1616

17-
~~~jsx
17+
~~~ts
1818
type Id = string | number;
1919
add(newItem: IDataItem | IDataItem[], index?: number): Id | Id[];
2020
~~~

docs/data_collection/api/datacollection_changeid_method.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ description: You can explore the changeId method of DataCollection in the docume
1212

1313
@params:
1414
- `id: string | number` - the old id of an item
15-
- `newId?: string | number` - optional, the new id; auto-generated if not set
15+
- `newId: string | number` - the new id; auto-generated if not set
1616
- `silent?: boolean` - optional, if set to *true*, the method will be called without triggering events; otherwise, *false*
1717

1818
@example:

docs/data_collection/api/datacollection_getsortingstates_method.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ description: You can explore the getSortingStates method of DataCollection in th
88

99
@short: returns an array of objects with the current parameters of sorting applied to the data
1010

11-
## Usage
11+
#### Usage
1212

13-
~~~jsx
13+
~~~ts
1414
interface ISortingState {
1515
by: string | number,
1616
dir: "asc" | "desc",

docs/data_collection/api/datacollection_group_method.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Data grouping isn't intended for working with [`lazyDataProxy`](helpers.md/lazyd
1616
Grouped data can be serialized. After serialization data is available for rendering and editing as a plain tree-like structure
1717
:::
1818

19-
## Usage
19+
#### Usage
2020

21-
~~~jsx {16}
21+
~~~ts {16}
2222
type TGroupOrderFunc = (item: IDataItem) => string;
2323
type TAggregate = "sum" | "count" | "min" | "max" | "avg" | string;
2424
interface IGroupOrder {

docs/data_collection/api/datacollection_reduce_method.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ description: You can explore the reduce method of DataCollection in the document
88

99
@short: reduces the array to a single value
1010

11-
@signature: {'reduce(callback: (acc: any, IDataItem: any, index: number) => any, acc: any): any;'}
11+
#### Usage
12+
13+
~~~ts
14+
type ReduceCallBack<IDataItem, A> = (acc: A, item: IDataItem, index: number) => A;
15+
reduce<A>(callback: ReduceCallBack<IDataItem, A>, acc: A): A;
16+
~~~
1217

1318
@params:
1419

1520
- `callback: function` - a function that will be called for each item in the array. The function is called with the following parameters:
1621
- `acc: any` - the *initialValue*, or the previously returned value of the function
17-
- `IDataItem: any` - the current item of a data collection
22+
- `item: IDataItem` - the current item of a data collection
1823
- `index: number` - the index of the item
1924
- `acc: any` - a value to be passed to the function as the initial value
2025

docs/tree_collection/api/treecollection_getsortingstates_method.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ description: You can explore the getSortingStates method of TreeCollection in th
88

99
@short: returns an array of objects with the current parameters of sorting applied to the data
1010

11-
## Usage
11+
#### Usage
1212

13-
~~~jsx
13+
~~~ts
1414
interface ISortingState {
1515
by: string | number,
1616
dir: "asc" | "desc",

docs/tree_collection/api/treecollection_update_method.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ toolbar.data.update("add_btn", { value:"Add new" });
2626
Also note, that for correct work of the method the last update of a data collection should be done with the `silent:false` setting applied, for example:
2727

2828
~~~jsx
29-
const children = tree.data.findAll({ by: "parent", match: "folder_1" });
30-
const lastIndex = children.length - 1;
29+
const itemsForUpdate = [...]; // items { ... }
30+
const lastIndex = itemsForUpdate.length - 1;
3131

32-
children.forEach((item, index) => {
33-
tree.data.update(item.id, {
34-
icon: { file: "dxi dxi-file", folder: "dxi dxi-folder" },
32+
itemsForUpdate.forEach((item, index) => {
33+
data.update(item.id, {
34+
param: "change param",
3535
}, index != lastIndex); // the last update isn't silent, as the `silent:false` parameter is set
3636
});
3737
~~~

0 commit comments

Comments
 (0)