Skip to content

Commit 5fc0735

Browse files
Component "awes-io/table-builder" was updated to v1.2
1 parent 5881038 commit 5fc0735

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

docs/components/table-builder/1.2/tb-column.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,50 @@ It is a component of the column of dynamic tables. It is available for use only
6666
| **name (*)** | `String` | `undefined` | Name of key in the data object |
6767
| **label** | `String` | `undefined` | Column caption in the header |
6868
| **media** | `String` | `undefined` | Key of media expressions |
69+
| **sort** | `String` | `undefined` | Sort params for column. If empty string is given, default params will be used |
70+
71+
72+
### Sorting values in column
73+
74+
By default, all the columns are not sortable. To create a sortable column, simply pass the `sort` prop to the component
75+
76+
```html
77+
<tb-column name="my_column" sort></tb-column>
78+
```
79+
80+
Thus, default configuration of sortable columns will be used. To overwrite it globally, pass your own config to `AWES_CONFIG.tableBuilder`. The default config is:
81+
82+
```javascript
83+
{
84+
// ... some other config params
85+
sort: {
86+
param: 'orderBy', // <-- GET-param name in browser query string
87+
ascTemplate: '%s', // <-- template, where '%s' is replaced with column name
88+
descTemplate: '%s_desc'
89+
}
90+
}
91+
```
92+
93+
You may overwrite template values for each column, by passing custom values to sort param. Separate them with pipe sign `|`, first is for ascending order, second is for descending.
94+
95+
> Note that param name could not be configured for each column, it is configured globally
96+
97+
```html
98+
<!-- custom param values. Query string will look like: -->
99+
<!-- ...?orderBy=sort-ascending -->
100+
<!-- ...?orderBy=sort-descending -->
101+
<tb-column name="my_column" sort="sort-ascending|sort-descending"></tb-column>
102+
```
103+
104+
Sometimes, you may want to show, that by default table is sorted by some column. In this case you should omit the param value for the current column:
105+
106+
```html
107+
<!-- In case, table is sorted ascending by 'first_name' -->
108+
<tb-column name="first_name" sort="|first_name_desc"></tb-column>
109+
110+
<!-- In case, table is sorted descending by 'first_name' -->
111+
<tb-column name="first_name" sort="first_name"></tb-column>
112+
```
69113

70114

71115
## Component slots

0 commit comments

Comments
 (0)