A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/bootstrap-vue/bootstrap-vue/issues/3892 below:

Possibility to provide a sort value per field · Issue #3892 · bootstrap-vue/bootstrap-vue · GitHub

Is your feature request related to a problem? Please describe...

I use the BTable component for displaying some data and I have a lot of use cases, where my data items contain a field with a non user friendly internal name.

items: [
    { "internalName" : "internalValue" }
]

For displaying the field in the table, I use a formatter function.

fields: [
    {
       key:  "internalName",
       label: 'Label',
       formatter: (value, key, item) => this.dataMap[value].displayName
    }
]

I also want to make this field sortable. But sorting this value should be done by a related position/priority field in this.dataMap[value].position. This is currently only possible with workarounds that required boilerplate code.

Describe the solution you'd like

Possibility to provide a sorting value, similiar to the formatter:

fields:[ 
 { 
    key: 'internalName',
    label: 'Label',
    sortable: true,
    formatter: (value, key, item) => this.dataMap[value].displayName,
    sortBy: (value, key, item) => this.dataMap[value].position
 }
]
Describe alternatives you've considered

I know that I can provide my own sorting routine via the sort-compare option for the table. But this is a big overhead. Because I want the default behaviour with just another value to be used for sorting.

What I currently do is: Formatter function returns sorting value, sortByFormatted is set to true. And for displaying the value, I use the corresponding field slot, that translates the internal name to the display name.
But this way, I always have to define a slot and in general it looks like a dirty solution.


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