You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/components/table/README.md
+18-13Lines changed: 18 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -243,16 +243,16 @@ The following field properties are recognized:
243
243
|`formatter`| String or Function | A formatter callback function or name of a method in your component, can be used instead of (or in conjunction with) scoped field slots. Refer to [Custom Data Rendering](#custom-data-rendering) for more details. |
244
244
|`sortable`| Boolean | Enable sorting on this column. Refer to the [Sorting](#sorting) Section for more details. |
245
245
|`sortDirection`| String | Set the initial sort direction on this column when it becomes sorted. Refer to the [Change initial sort direction](#Change-initial-sort-direction) Section for more details. |
246
-
|`sortByFormatted`| Boolean | <spanclass="badge badge-info small">NEW in 2.0.0-rc.28</span> Sort the column by the result of the field's `formatter` callback function. Default is `false`. Has no effect if the field does not have a `formatter`. Refer to the [Sorting](#sorting) Section for more details.|
247
-
|`filterByFormatted`| Boolean | <spanclass="badge badge-info small">NEW in 2.0.0-rc.28</span> Filter the column by the result of the field's `formatter` callback function. Default is `false`. Has no effect if the field does not have a `formatter`. Refer to the [Filtering](#filtering) section for more details.|
246
+
|`sortByFormatted`| Boolean or Function|Sort the column by the result of the field's `formatter` callback function when set to `true`. Default is `false`. Boolean has no effect if the field does not have a `formatter`. Optionally accepts a formatter function _reference_ to format the value before sorting. Refer to the [Sorting](#sorting) Section for more details. |
247
+
|`filterByFormatted`| Boolean or Function|Filter the column by the result of the field's `formatter` callback function when set to `true`. Default is `false`. Boolean has no effect if the field does not have a `formatter`. Optionally accepts a formatter function _reference_ to format the value before filtering. Refer to the [Filtering](#filtering) section for more details. |
248
248
|`tdClass`| String or Array or Function | Class name (or array of class names) to add to `<tbody>` data `<td>` cells in the column. If custom classes per cell are required, a callback function can be specified instead. The function will be called as `tdClass( value, key, item )` and it may return an `Array` or `String`. |
249
249
|`thClass`| String or Array | Class name (or array of class names) to add to this field's `<thead>`/`<tfoot>` heading `<th>` cell. |
250
250
|`thStyle`| Object | JavaScript object representing CSS styles you would like to apply to the table `<thead>`/`<tfoot>` field `<th>`. |
251
251
|`variant`| String | Apply contextual class to all the `<th>`**and**`<td>` in the column - `active`, `success`, `info`, `warning`, `danger`. These variants map to classes `thead-${variant}` (in the header), `table-${variant}` (in the body), or `bg-${variant}` (when the prop `dark` is set). |
252
252
|`tdAttr`| Object or Function | JavaScript object representing additional attributes to apply to the `<tbody>` field `<td>` cell. If custom attributes per cell are required, a callback function can be specified instead. The function will be called as `tdAttr( value, key, item )` and it may return an `Object`. |
253
253
|`thAttr`| Object or Function | JavaScript object representing additional attributes to apply to the field's `<thead>`/`<tfoot>` heading `<th>` cell. If the field's `isRowHeader` is set to `true`, the attributes will also apply to the `<tbody>` field `<th>` cell. If custom attributes per cell are required, a callback function can be specified instead. The function will be called as `thAttr( value, key, item, type )` and it may return an `Object`. |
254
254
|`isRowHeader`| Boolean | When set to `true`, the field's item data cell will be rendered with `<th>` rather than the default of `<td>`. |
255
-
|`stickyColumn`| Boolean |<spanclass="badge badge-info small">NEW in 2.0.0-rc.28</span> When set to `true`, and the table in in [responsive](#responsive-tables) mode or has [sticky headers](#sticky-headers), will cause the column to become fixed to the left when the table's horizontal scrollbar is scrolled. See [Sticky columns](#sticky-columns) for more details |
255
+
|`stickyColumn`| Boolean | When set to `true`, and the table in in [responsive](#responsive-tables) mode or has [sticky headers](#sticky-headers), will cause the column to become fixed to the left when the table's horizontal scrollbar is scrolled. See [Sticky columns](#sticky-columns) for more details|
256
256
257
257
**Notes:**
258
258
@@ -1729,9 +1729,10 @@ if it is an object and then sorted.
1729
1729
data: scoped slots are used only for _presentation only_, and do not affect the underlying data.
1730
1730
- Fields that have a [`formatter` function](#formatter-callback) (virtual field or regular field)
1731
1731
can be sorted by the value returned via the formatter function if the
1732
-
[field](#field-definition-reference) property `sortByFormatted` is set to `true`. The default is
1733
-
`false` which will sort by the original field value. This is only applicable for the built-in
1734
-
sort-compare routine.
1732
+
[field](#field-definition-reference) property `sortByFormatted` is set to `true`. Optionally you
1733
+
can pass a formatter function reference to `sortByFormatted` to format the value before sorting.
1734
+
The default is `false` which will sort by the original field value. This is only applicable for
1735
+
the built-in sort-compare routine.
1735
1736
- By default, the internal sorting routine will sort `null`, `undefined`, or empty string values
1736
1737
first (less than any other values). To sort so that `null`, `undefined` or empty string values
1737
1738
appear last (greater than any other value), set the `sort-null-last` prop to `true`.
@@ -1818,11 +1819,13 @@ optional:
1818
1819
- the third argument is the field `key` being sorted on (`sortBy`)
1819
1820
- the fourth argument (`sortDesc`) is the order `<b-table>` will be displaying the records (`true`
1820
1821
for descending, `false` for ascending)
1821
-
- the fifth argument is a reference to the field's [formatter function](#formatter-callback) (or
1822
-
`undefined` if no field formatter). You will need to call this method to get the formatted field
1823
-
value: `valA = formatter(a[key], key, a)` and `valB = formatter(b[key], key, b)`, if you need to
1824
-
sort by the formatted value. This will be `undefined` if the field's `sortByFormatted` property is
1825
-
not `true`
1822
+
- the fifth argument is a reference to the field's [formatter function](#formatter-callback) or the
1823
+
field's `filterByFormatted` value if it is a function reference. If not formatter is found this
1824
+
value will be `undefined`. You will need to call this method to get the formatted field value:
1825
+
`valA = formatter(a[key], key, a)` and `valB = formatter(b[key], key, b)`, if you need to sort by
1826
+
the formatted value. This will be `undefined` if the field's `sortByFormatted` property is not
1827
+
`true` or is not a formatter function _reference_, or the fields formatter function cannot be
1828
+
found.
1826
1829
- the sixth argument is the value of the `sort-compare-options` prop (default is
1827
1830
`{ numeric: true }`)
1828
1831
- the seventh argument is the value of the `sort-compare-locale` prop (default is `undefined`)
@@ -1843,7 +1846,7 @@ Your custom sort-compare routine can also return `null` or `false`, to fall back
1843
1846
sort-compare routine_ for the particular `key`. You can use this feature (i.e. by returning `null`)
1844
1847
to have your custom sort-compare routine handle _only_ certain fields (keys) such as the special
1845
1848
case of virtual (scoped slot) columns, and have the internal (built in) sort-compare handle all
1846
-
other fields.
1849
+
_other_ fields.
1847
1850
1848
1851
The default sort-compare routine works similar to the following. Note the fourth argument (sorting
1849
1852
direction) is **not** used in the sort comparison:
@@ -1950,7 +1953,9 @@ There are several options for controlling what data the filter is applied agains
1950
1953
- Normally, `<b-table>` filters based on the stringified record data. If the field has a `formatter`
1951
1954
function specified, you can optionally filter based on the result of the formatter by setting the
1952
1955
[field definition property](#field-definition-reference)`filterByFormatted` to `true`. If the
1953
-
field does not have a formatter function, this option is ignored.
1956
+
field does not have a formatter function, this option is ignored. You can optionally pass a
1957
+
formatter function _reference_, to be used for filtering only, to the field definition property
1958
+
`filterByFormatted`.
1954
1959
1955
1960
The props `filter-ignored-fields` and `filter-included-fields`, and the field definition property
1956
1961
`filterByFormatted` have no effect when using a [custom filter function](#custom-filter-function),
0 commit comments