Skip to content

Commit a77b1b4

Browse files
authored
Merge pull request #60 from DHTMLX/update-datacollection-api
[update] datacollection api descriptions
2 parents 3e24931 + fdc845f commit a77b1b4

51 files changed

Lines changed: 285 additions & 206 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/data_collection/api/datacollection_add_method.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,23 @@ 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+
~~~ts
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
19-
- `index: number` - optional, the index of the position starting from which new items will be added
23+
- `newItem: IDataItem | IDataItem[]` - the object of a new item or an array of item objects
24+
- `index?: number` - optional, the index of the position starting from which new items will be added
2025

2126
@returns:
2227
Either item's id or an array with ids of items.
2328

2429
@example:
2530
// adding a new item into the beginning of a data collection
26-
component.data.add({"value": 57.44787660011765, "id": "u1565340894584"},0);
31+
component.data.add({ "value": 57.44787660011765, "id": "u1565340894584" }, 0);
2732

2833
// adding an array of new items into a data collection
2934
component.data.add([

docs/data_collection/api/datacollection_changeid_method.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ 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
16-
- `silent: boolean` - true, to prevent changing the id; otherwise, false
15+
- `newId: string | number` - the new id; auto-generated if not set
16+
- `silent?: boolean` - optional, if set to *true*, the method will be called without triggering events; otherwise, *false*
1717

1818
@example:
1919
component.data.changeId("1", "22");

docs/data_collection/api/datacollection_copy_method.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ description: You can explore the copy method of DataCollection in the documentat
1313
@params:
1414
- `id: (string | number) | (string | number)[]` - the id of an item or an array with ids of items to copy
1515
- `index: number` - the index to create a copy at
16-
- `target: object` - optional, the target data collection object
16+
- `target?: object` - optional, the target data collection object
1717

1818
@returns:
1919
The item's id or an array with ids of items.
2020

2121
@example:
22-
component.data.copy("4",5); // copies the item with id:4 to the position with index 5
22+
component.data.copy("4", 5); // copies the item with id:4 to the position with index 5
2323

2424
@descr:
2525

docs/data_collection/api/datacollection_filter_method.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,28 @@ description: You can explore the filter method of DataCollection in the document
88

99
@short: filters data items in a component
1010

11-
@signature: {'filter(rule?: function | object, config?: object): string;'}
11+
@signature: {'filter(rule?: function | object, config?: object, silent?: boolean): string;'}
1212

1313
@params:
14-
- `rule: function | object` - the filtering criteria
15-
- If set as a *function*, filtering will be applied by the rule specified in the function. The function takes an object of a data item as a parameter and returns *true/false*
14+
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*
1617
- If set as an *object*, the parameter has the following attributes:
17-
- `by: string | number` - mandatory, the id of a data field
18-
- `match: string` - mandatory, a pattern to match
19-
- `compare: function` - optional, a function for extended filtering that takes three parameters:
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:
2021
- `value` - the value to compare
2122
- `match` - a pattern to match
2223
- `item` - a data item the values of which should be compared
23-
- `config: object` - optional, defines the parameters of filtering. It may contain the following properties:
24-
- `id: string` - optional, the id of the filter
25-
- `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)
26-
- `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
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
29+
30+
:::info
31+
Note that after calling the method with the `silent:true` parameter, you may need to repaint the component with the `paint()` method.
32+
:::
2733

2834
@returns:
2935
- `id: string` - the id of the filter

docs/data_collection/api/datacollection_find_method.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,31 @@ 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:
1515
- if set as an object, the parameter contains the following attributes:
1616
- `by: string | function` - the search criterion (either the key of the item attribute or a search function)
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:
19-
- `item` - (required) the object of an item
20-
- `index` - (optional) the index of an item
21-
- `array` - (optional) an array with items
19+
- `item: object` - the object of an item
20+
- `index: number` - the index of an item
21+
- `array: object[]` - an array of items the method was called upon
2222

2323
@returns:
24-
An object of the matching item.
24+
The object of the matching item.
2525

2626
@example:
27-
//searching for an item by the function
28-
const item = component.data.find(function(item){
29-
if(item.text==="Manager"||item.text==="Marketer"){return true}
27+
// searching for an item by the function
28+
const item = component.data.find(function (item) {
29+
if (item.text === "Manager" || item.text === "Marketer") {
30+
return true
31+
}
3032
});
3133

32-
//searching for an item by the attribute key
33-
const item = component.data.find({by:"text",match:"Manager"});
34+
// searching for an item by the attribute key
35+
const item = component.data.find({ by: "text", match: "Manager" });
3436

3537
@descr:
3638

docs/data_collection/api/datacollection_findall_method.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,31 @@ 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:
1515
- if set as an object, the parameter contains the following attributes:
1616
- `by: string | function` - the search criterion (either the key of the item attribute or a search function)
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:
19-
- `item` - (required) the object of an item
20-
- `index` - (optional) the index of an item
21-
- `array` - (optional) an array with items
19+
- `item: object` - the object of an item
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.
2525

2626
@example:
27-
//searching for items by the function
28-
const items = component.data.findAll(function(items){
29-
if(items.text==="Manager"||items.text==="Marketer"){return true}
27+
// searching for items by the function
28+
const items = component.data.findAll(function (items) {
29+
if (items.text === "Manager" || items.text === "Marketer") {
30+
return true
31+
}
3032
});
3133

32-
//searching for items by the attribute key
33-
const items = component.data.findAll({by:"text",match:"Manager"});
34+
// searching for items by the attribute key
35+
const items = component.data.findAll({ by: "text", match: "Manager" });
3436

3537
@descr:
3638

docs/data_collection/api/datacollection_foreach_method.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ 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:
15-
- `item` - the object of an item
16-
- `index` - the index of an item
17-
- `array` - an array of items the method was called upon
15+
- `item: object` - the object of an item
16+
- `index: number` - the index of an item
17+
- `array: object[]` - an array of items the method was called upon
1818

1919
@example:
20-
component.data.forEach(function(item, index, array) {
20+
component.data.forEach(function (item, index, array) {
2121
console.log("This is an item of dataCollection: ", item);
2222
console.log("This is an index of the element: ", index);
2323
console.log("This is an array of the elements: ", array);

docs/data_collection/api/datacollection_getfilters_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 getFilters method of DataCollection in the docu
1212

1313
@params:
1414

15-
- `permanent: boolean` - optional, <i>false</i> by default. Allows getting the list of permanent filters
15+
- `permanent?: boolean` - optional, *false* by default. Allows getting the list of permanent filters
1616

1717
@returns:
1818
- `filters: object` - an object with the applied filters, where the key is the id of a filter and the value is an object with the [`rule` and `config` properties](data_collection/api/datacollection_filter_method.md)

docs/data_collection/api/datacollection_getitem_method.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const item = component.data.getItem(123);
2626

2727
You can access the original properties of an item like this:
2828

29-
~~~js
29+
~~~jsx
3030
const item = component.data.getItem(123);
3131
const text = item.text;
3232
~~~

docs/data_collection/api/datacollection_getlength_method.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ description: You can explore the getLength method of DataCollection in the docum
1414
The number of elements of a data collection.
1515

1616
@example:
17-
component.data.getLength();
17+
const dataLength = component.data.getLength();
1818

1919
@descr:
2020

0 commit comments

Comments
 (0)