+26
-4
lines changedFilter options
+26
-4
lines changed Original file line number Diff line number Diff line change
@@ -242,6 +242,7 @@ The following field properties are recognized:
242
242
| `class` | String or Array | Class name (or array of class names) to add to `<th>` **and** `<td>` in the column. |
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. The formatter will be called with the syntax `formatter(value, key, item)`. 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
+
| `sortKey` | String | <span class="badge badge-secondary">v2.17.0+</span> Set the value of `sortBy` for the column in the emitted context when `no-local-sorting` is `true`. |
245
246
| `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
247
| `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 for sorting purposes only. Refer to the [Sorting](#sorting) Section for more details. |
247
248
| `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 for filtering purposes only. Refer to the [Filtering](#filtering) section for more details. |
@@ -2048,7 +2049,7 @@ function toString(value) {
2048
2049
### Disable local sorting
2049
2050
2050
2051
If you want to handle sorting entirely in your app, you can disable the local sorting in `<b-table>`
2051
-
by setting the prop `no-local-sorting` to true, while still maintaining the sortable header
2052
+
by setting the prop `no-local-sorting` to `true`, while still maintaining the sortable header
2052
2053
functionality (via `sort-changed` or `context-changed` events as well as syncable props).
2053
2054
2054
2055
You can use the syncable props `sort-by.sync` and `sort-desc.sync` to detect changes in sorting
@@ -2059,7 +2060,7 @@ with a single argument containing the context object of `<b-table>`. See the
2059
2060
[Detection of sorting change](#detection-of-sorting-change) section below for details about the
2060
2061
sort-changed event and the context object.
2061
2062
2062
-
When `no-local-sorting` is true, the `sort-compare` prop has no effect.
2063
+
When `no-local-sorting` is `true`, the `sort-compare` prop has no effect.
2063
2064
2064
2065
### Change initial sort direction
2065
2066
Original file line number Diff line number Diff line change
@@ -209,12 +209,13 @@ export default {
209
209
}
210
210
}
211
211
if (field.sortable) {
212
-
if (key === this.localSortBy) {
212
+
const sortKey = !this.localSorting && field.sortKey ? field.sortKey : key
213
+
if (this.localSortBy === sortKey) {
213
214
// Change sorting direction on current column
214
215
this.localSortDesc = !this.localSortDesc
215
216
} else {
216
217
// Start sorting this column ascending
217
-
this.localSortBy = key
218
+
this.localSortBy = sortKey
218
219
// this.localSortDesc = false
219
220
toggleLocalSortDesc()
220
221
}
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ export declare class BTable extends BvComponent {
24
24
fields?: BvTableFieldArray
25
25
primaryKey?: string
26
26
sortBy?: string | null
27
+
sortKey?: string
27
28
sortDesc?: boolean
28
29
sortDirection?: BvTableSortDirection
29
30
sortCompare?: BvTableSortCompareCallback
Original file line number Diff line number Diff line change
@@ -41,6 +41,25 @@ describe('table > sorting', () => {
41
41
wrapper.destroy()
42
42
})
43
43
44
+
it('should emit `field.sortKey` if specified and no local sorting', async () => {
45
+
const wrapper = mount(BTable, {
46
+
propsData: {
47
+
fields: [...testFields, { key: 'd', label: 'D', sortable: true, sortKey: 'non-local' }],
48
+
items: testItems,
49
+
noLocalSorting: true
50
+
}
51
+
})
52
+
53
+
expect(wrapper).toBeDefined()
54
+
55
+
await wrapper
56
+
.findAll('thead > tr > th')
57
+
.at(3)
58
+
.trigger('keydown.enter')
59
+
expect(wrapper.emitted('sort-changed').length).toBe(1)
60
+
expect(wrapper.emitted('sort-changed')[0][0].sortBy).toEqual('non-local')
61
+
})
62
+
44
63
it('should sort column descending when sortBy set and sortDesc changed, with proper attributes', async () => {
45
64
const wrapper = mount(BTable, {
46
65
propsData: {
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4