-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add DataCollection guides #56
base: master
Are you sure you want to change the base?
Changes from 11 commits
111fddf
53685a8
7fd6f3c
cecd994
4cbdc04
eae88b2
5306d60
121166a
895060e
7ca5401
d506868
4f3d192
9a126e0
8556cb3
088a226
40e6cbc
8559ddd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ description: You can explore the filter method of DataCollection in the document | |
|
||
@short: filters data items in a component | ||
|
||
@signature: {'filter(rule?: function | object, config?: object): string;'} | ||
@signature: {'filter(rule?: function | object, config?: object, silent?: boolean): string;'} | ||
|
||
@params: | ||
- `rule: function | object` - the filtering criteria | ||
|
@@ -22,8 +22,13 @@ description: You can explore the filter method of DataCollection in the document | |
- `item` - a data item the values of which should be compared | ||
- `config: object` - optional, defines the parameters of filtering. It may contain the following properties: | ||
- `id: string` - optional, the id of the filter | ||
- `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) | ||
- `add: boolean` - optional, defines whether each next filtering will be applied to the already filtered data (*true*), or to the initial data (*false*, default) | ||
- `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 | ||
- `silent: boolean` - optional, if *true*, the update of the DataCollection state won't trigger the component repainting, *false* by default | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mafanya23 откуда тут перерисовка?)) Это частный случай, а может и сработает. Можно в примечаниях написать, что:
Флаг |
||
|
||
:::info | ||
Note that the use of the `silent` parameter may cause incorrect behavior of the method. | ||
::: | ||
|
||
@returns: | ||
- `id: string` - the id of the filter | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ description: You can explore the find method of DataCollection in the documentat | |
- `array` - (optional) an array with items | ||
|
||
@returns: | ||
An object of the matching item. | ||
The object of the matching item. | ||
|
||
@example: | ||
//searching for an item by the function | ||
|
@@ -30,7 +30,7 @@ const item = component.data.find(function(item){ | |
}); | ||
|
||
//searching for an item by the attribute key | ||
const item = component.data.find({by:"text",match:"Manager"}); | ||
const item = component.data.find({ by:"text",match:"Manager" }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mafanya23 понимаю, что правка локальная. Если есть возможность, поправ пожалуйста отступы в примерах: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mafanya23 почти во всех примерах есть такая проблема |
||
|
||
@descr: | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ description: You can explore the getLength method of DataCollection in the docum | |
The number of elements of a data collection. | ||
|
||
@example: | ||
component.data.getLength(); | ||
const items = component.data.getLength(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mafanya23 метод возвращает длину коллекции. Название переменной можно было назвать There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mafanya23 по описанию подавлю. В |
||
|
||
@descr: | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,20 +8,21 @@ description: You can explore the reduce method of DataCollection in the document | |
|
||
@short: reduces the array to a single value | ||
|
||
@signature: {'reduce(callback: (acc: any, item: any) => any, acc: any): any;'} | ||
@signature: {'reduce(callback: (acc: any, item: any, index?: number) => any, acc: any): any;'} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mafanya23 |
||
|
||
@params: | ||
|
||
- `callback: function` - a function that will be called for each item in the array. The function takes two parameters: | ||
- `acc` - the <i>initialValue</i>, or the previously returned value of the function | ||
- `callback: function` - a function that will be called for each item in the array. The function is called with the following parameters: | ||
- `acc` - the *initialValue*, or the previously returned value of the function | ||
- `item` - the current item of a data collection | ||
- `index` - the index of the item | ||
- `acc: any` - a value to be passed to the function as the initial value | ||
|
||
@returns: | ||
A single output value. | ||
|
||
@example: | ||
const total = component.data.reduce(function(acc, item) { | ||
const total = component.data.reduce(function(acc, item, index) { | ||
return acc + item.value; | ||
}, 0); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ description: You can explore the remove method of DataCollection in the document | |
@example: | ||
component.data.remove("2"); | ||
//or | ||
component.data.remove(["2", "4"]); | ||
component.data.remove([ "2", "4" ]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mafanya23 в массивах так не делай, тут все было корректно. После "[" или "]" отступа нет |
||
|
||
@descr: | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,17 @@ description: You can explore the resetFilter method of DataCollection in the doc | |
|
||
@short: resets the active filters | ||
|
||
@signature: {'resetFilter(config?: object): boolean;'} | ||
@signature: {'resetFilter(config?: object, silent?: boolean): boolean;'} | ||
|
||
@params: | ||
- `config: object` - optional, specifies the parameters of resetting the active filters. If the config isn't specified or it is empty, all the filters except for those that have the **permanent** property in the configuration object will be reset. Can contain the following properties: | ||
- `config: object` - optional, specifies the parameters of resetting the active filters. If the config isn't specified or it is empty, all the filters except for those that have the `permanent` property in the configuration object will be reset. Can contain the following properties: | ||
- `id: string` - optional, the id of the filter to reset | ||
- `permanent: boolean` - optional, *true* to reset all the active filters, including those that have the **permanent:true** property in their config | ||
- `permanent: boolean` - optional, *true* to reset all the active filters, including those that have the `permanent:true` property in their config | ||
- `silent: boolean` - optional, if *true*, the update of the DataCollection state won't trigger the component repainting, *false* by default | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mafanya23 выше уже писал. Этот параметр никак с перерисовкой не связан. Он просто делает метод "тихим", и не кидает события. Перерисовка может потребоваться, но это не должно быть в описании, и не является конечным назначением данного параметра. |
||
|
||
:::info | ||
Note that the use of the `silent` parameter may cause incorrect behavior of the method. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mafanya23 выше писал. Тут как раз можно и написать, что в определенных компонентах вам может потребоваться принудительная перерисовка методом |
||
::: | ||
|
||
@returns: | ||
- `result: boolean` - *true*, if all the filters, including the permanent ones, have been reset; otherwise *false* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ description: You can explore the sort method of DataCollection in the documentat | |
- `as: function` - a function that specifies the type to sort data as | ||
- `rule: function` - optional, a sorting rule; the function must have two parameters and return a number (-1,0,1) | ||
- `config: object` - defines the parameter of sorting. It may contain one property: | ||
- `smartSorting: boolean` - specifies whether a sorting rule should be applied each time after changing the data set | ||
- `smartSorting: boolean` - optional, specifies whether a sorting rule should be applied each time after changing the data set | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mafanya23 заметил, что от метода к методу формат описания меняется. Иногда приводятся сигнатуры, как тут, а иногда нет. Если сигнатуры приводим. То тут нужен знак опциональности - config?: object
- smartSorting?: boolean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Хотелось бы видеть на всех страницах одинаковый подход. |
||
|
||
@example: | ||
grid.data.sort( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,16 @@ description: You can explore the update method of DataCollection in the document | |
|
||
@short: updates properties of the item | ||
|
||
@signature: {'update?: (id: string | number, newItem: object) => void;'} | ||
@signature: {'update?: (id: string | number, newItem: object, silent?: boolean) => void;'} | ||
|
||
@params: | ||
- `id: string | number` - the id of the item which needs to be updated | ||
- `newItem: object` - a hash of properties which need to be updated | ||
- `silent: boolean` - optional, if *true*, the update of the DataCollection state won't trigger the component repainting, *false* by default | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mafanya23 выше есть подробное описание данного аргумента. В целом перерисовка никак не связана с данным аргументом, все зависит от того, что мы делаем под капотом. Аргумент влияет на вызов событий. Для Можно такой пример привести, он рабочий только для const lastIndex = data.getLength() - 1;
data.forEach((item, index) => {
data.update(item.id, {
param: "change param",
}, index != lastIndex); // last update not silent
}); |
||
|
||
:::info | ||
Note that the use of the `silent` parameter may cause incorrect behavior of the method. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mafanya23 смотрим комментарии выше |
||
::: | ||
|
||
@example: | ||
component.data.update(123, { text:"New text" }); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mafanya23 кажется тут не то описание.
silent
- если использовать метод с включенным данным флагом, метод будет работать в "тихом" режиме, то есть - без вызова событий. Метод сработает, события будут проигнорированы.