Skip to content

Commit 9ef717a

Browse files
committed
[update] correct data/treecollection api descriptions
1 parent 77a260a commit 9ef717a

37 files changed

Lines changed: 171 additions & 131 deletions

docs/data_collection/api/datacollection_add_method.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ 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-
@signature: {'add(new_item: object | object[], index?: number): (string | number) | (string | number)[];'}
15+
### Usage
16+
17+
~~~jsx
18+
type Id = string | number;
19+
add(newItem: IDataItem | IDataItem[], index?: number): Id | Id[];
20+
~~~
1621

1722
@params:
18-
- `new_item: object | array` - the object of a new item or an array of item objects
23+
- `newItem: IDataItem | IDataItem[]` - the object of a new item or an array of item objects
1924
- `index?: number` - optional, the index of the position starting from which new items will be added
2025

2126
@returns:

docs/data_collection/api/datacollection_filter_method.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,20 @@ description: You can explore the filter method of DataCollection in the document
1212

1313
@params:
1414

15-
<table>
16-
<tbody>
17-
<tr>
18-
<td><b>rule</b></td>
19-
<td>(<i>function | object</i>) optional, the filtering criteria. It can be:<ul><li>a filtering function. It takes as a parameter a data item and returns <i>true/false</i></li><li>an object with the following attributes:<ul><li><b>`by?: string | number`</b> - optional, the id of a column</li><li><b>`match?: string`</b> - optional, a pattern to match </li><li><b>`compare?: function`</b> - optional, a function for extended filtering that takes the following parameters:<ul><li><b>value</b> - the value to compare </li><li><b>match</b> - a pattern to match </li><li><b>item</b> - a data item the values of which should be compared</li></ul></li></ul></li></ul></td>
20-
</tr>
21-
<tr>
22-
<td><b>config</b></td>
23-
<td>(<i>object</i>) optional, an object with the following properties:<ul><li><b>`id?: string`</b> - optional, the id of the filter</li><li><b>`add?: boolean`</b> - optional, defines whether each next filtering will be applied to the already filtered data (<i>true</i>), or to the initial data (<i>false</i>, default)</li><li><b>`permanent?: boolean`</b> - optional, <i>true</i> to make the current filter permanent. It will be applied even if the next filtering doesn't have the <b>`add:true`</b> property in its configuration object. Such a filter can be removed just with the <a href="../datacollection_resetfilter_method/">`resetFilter()`</a> method</li></ul></td>
24-
</tr>
25-
<tr>
26-
<td><b>silent</b></td>
27-
<td>(<i>boolean</i>) optional, if set to <i>true</i>, the method will be called without triggering events, <i>false</i> by default</td>
28-
</tr>
29-
</tbody>
30-
</table>
15+
- `rule?: function | object` - optional, the filtering criteria
16+
- If set as a *function*, filtering will be applied by the rule specified in the function. It takes as a parameter a data item and returns *true/false*
17+
- If set as an *object*, the parameter has the following attributes:
18+
- `by?: string | number` - optional, the id of a data field
19+
- `match?: string` - optional, a pattern to match
20+
- `compare?: function` - optional, a function for extended filtering that takes the following parameters:
21+
- `value` - the value to compare
22+
- `match` - a pattern to match
23+
- `item` - a data item the values of which should be compared
24+
- `config?: object` - optional, an object with the following properties:
25+
- `id?: string` - optional, the id of the filter
26+
- `add?: boolean` - optional, defines whether each next filtering will be applied to the already filtered data (<i>true</i>), or to the initial data (<i>false</i>, default)
27+
- `permanent?: boolean` - optional, *true* to make the current filter permanent. It will be applied even if the next filtering doesn't have the `add:true` property in its configuration object. Such a filter can be removed just with the [resetFilter()](data_collection/api/datacollection_resetfilter_method.md) method
28+
- `silent?: boolean` - optional, if set to <i>true</i>, the method will be called without triggering events, <i>false</i> by default
3129

3230
:::info
3331
Note that after calling the method with the `silent:true` parameter, you may need to repaint the component with the `paint()` method.

docs/data_collection/api/datacollection_find_method.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: You can explore the find method of DataCollection in the documentat
88

99
@short: finds the item that corresponds to the specified rule
1010

11-
@signature: {'find(rule: object | (item: object, index?: number, array?: object[]) => any): object;'}
11+
@signature: {'find(rule: object | (item: object, index: number, array: object[]) => any): object;'}
1212

1313
@params:
1414
- `rule: object | function` - the search criteria:
@@ -17,8 +17,8 @@ description: You can explore the find method of DataCollection in the documentat
1717
- `match: string` - the value of the item attribute
1818
- if set as a function, the search will be applied by the rule specified in the function. The function takes three parameters:
1919
- `item: object` - the object of an item
20-
- `index?: number` - optional, the index of an item
21-
- `array?: object[]` - optional, an array of items the method was called upon
20+
- `index: number` - the index of an item
21+
- `array: object[]` - an array of items the method was called upon
2222

2323
@returns:
2424
The object of the matching item.

docs/data_collection/api/datacollection_findall_method.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: You can explore the findAll method of DataCollection in the documen
88

99
@short: finds all the items that correspond to the specified rule
1010

11-
@signature: {'findAll(rule: object | (item: object, index?: number, array?: object[]) => any): object[];'}
11+
@signature: {'findAll(rule: object | (item: object, index: number, array: object[]) => any): object[];'}
1212

1313
@params:
1414
- `rule: object | function` - the search criteria:
@@ -17,8 +17,8 @@ description: You can explore the findAll method of DataCollection in the documen
1717
- `match: string` - the value of the item attribute
1818
- if set as a function, the search will be applied by the rule specified in the function. The function takes three parameters:
1919
- `item: object` - the object of an item
20-
- `index?: number` - optional, the index of an item
21-
- `array?: object[]` - optional, an array of items the method was called upon
20+
- `index: number` - the index of an item
21+
- `array: object[]` - an array of items the method was called upon
2222

2323
@returns:
2424
An array of matching item objects.

docs/data_collection/api/datacollection_foreach_method.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ description: You can explore the forEach method of DataCollection in the documen
88

99
@short: iterates over all items of a data collection
1010

11-
@signature: {'forEach(callback: (item: object, index?: number, array?: object[]) => any): void;'}
11+
@signature: {'forEach(callback: (item: object, index: number, array: object[]) => any): void;'}
1212

1313
@params:
1414
- `callback: function` - a function that will iterate over items of a data collection. The function is called with the following parameters:
1515
- `item: object` - the object of an item
16-
- `index?: number` - optional, the index of an item
17-
- `array?: object[]` - optional, an array of items the method was called upon
16+
- `index: number` - the index of an item
17+
- `array: object[]` - an array of items the method was called upon
1818

1919
@example:
2020
component.data.forEach(function (item, index, array) {

docs/data_collection/api/datacollection_load_method.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: You can explore the load method of DataCollection in the documentat
88

99
@short: loads data from an external file
1010

11-
@signature: {'load(url: string | DataProxy, driver?: object | string): Promise<any>;'}
11+
@signature: {'load(url: string | IDataProxy, driver?: object | string): Promise<any>;'}
1212

1313
@params:
1414

docs/data_collection/api/datacollection_map_method.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ description: You can explore the map method of DataCollection in the documentati
88

99
@short: iterates through all the items of the component
1010

11-
@signature: {'map(callback: (item: object, index?: number, array?: object[]) => any): object[];'}
11+
@signature: {'map(callback: (item: object, index: number, array: object[]) => any): object[];'}
1212

1313
@params:
1414
- `callback: function` - a function that will be called for each item of a component. The function is called with the following parameters:
1515
- `item: object` - the object of an item
16-
- `index?: number` - optional, the index of an item
17-
- `array?: object[]` - optional, an array of items the method was called upon
16+
- `index: number` - the index of an item
17+
- `array: object[]` - an array of items the method was called upon
1818

1919
@returns:
2020
A new array of items where each item is the result of the callback function.

docs/data_collection/api/datacollection_maprange_method.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ description: You can explore the mapRange method of DataCollection in the docume
88

99
@short: returns a new array of the items according to the specified parameters
1010

11-
@signature: {'mapRange(from: number, to: number, callback: (item: object, index?: number, array?: object[]) => any): object[];'}
11+
@signature: {'mapRange(from: number, to: number, callback: (item: object, index: number, array: object[]) => any): object[];'}
1212

1313
@params:
1414
- `from: number` - the initial position of an item in the range
1515
- `to: number` - the final position of an item in the range
1616
- `callback: function` - a function that will be called for each item from the specified range. The function is called with the following parameters:
1717
- `item: object` - the object of an item
18-
- `index?: number` - optional, the index of an item
19-
- `array?: object[]` - optional, an array of items the method was called upon
18+
- `index: number` - the index of an item
19+
- `array: object[]` - an array of items the method was called upon
2020

2121
@returns:
2222
A new array of matching item objects.

docs/data_collection/api/datacollection_reduce_method.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ 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, item: any, index: number) => any, acc: any): any;'}
11+
@signature: {'reduce(callback: (acc: any, IDataItem: any, index: number) => any, acc: any): any;'}
1212

1313
@params:
1414

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

2121
@returns:
2222
A single output value.
2323

2424
@example:
25-
const total = component.data.reduce(function (acc, item, index) {
26-
return acc + item.value;
25+
const total = component.data.reduce(function (acc, IDataItem, index) {
26+
return acc + IDataItem.value;
2727
}, 0);
2828

2929
@descr:

docs/data_collection/api/datacollection_save_method.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ return data.saveData.then(function () {
3838
});
3939
~~~
4040

41-
Use the [`isSaved`](data_collection/api/datacollection_issaved_method.md) method to know whether the changes are saved:
41+
Use the [`isSaved`](data_collection/api/datacollection_issaved_method.md) method to check whether the changes are saved:
4242

4343
~~~jsx
4444
grid.data.saveData.then(function () {

0 commit comments

Comments
 (0)