Notification texts go here Contact Us Buy Now!

How to display modified text from data member in :items object array for item-title in v-select (Vuetify) dropdown list?

You can use the v-list-item component to customize item-title:

<template>
    <v-select label="User" :items="items" item-title="name">
        <template v-slot:item="{ props, item }">
            <v-list-item
                v-bind="props"
                :title="`${item.title} - ${item.value}`"
            ></v-list-item>
        </template>
    </v-select>
</template>

<script>
    export default {
        data: () => ({
            items: [
                {
                    name: 'John',
                    department: 'Marketing',
                },
                {
                    name: 'Jane',
                    department: 'Engineering',
                },
                {
                    name: 'Joe',
                    department: 'Sales',
                },
                {
                    name: 'Janet',
                    department: 'Engineering',
                },
                {
                    name: 'Jake',
                    department: 'Marketing',
                },
                {
                    name: 'Jack',
                    department: 'Sales',
                },
            ],
        }),
    }
    </script>

if you want to implement more than one line logic you can change it :title='myCustomTitle()' to a method

<v-select 
    label="Select a permission to copy"
    variant="underlined"
    no-data-text="No permission to choose from"
    :items="permissionsToCopy"
    v-model="selectedPermissionToCopy"
    return-object
>
    <template v-slot:selection="{item, props}">
        <v-list-item v-bind="props" style="padding: 0;" :title="convertToReadableText(item.value)"></v-list-item>
    </template>
    <template v-slot:item="{item, props}">
        <v-list-item v-bind="props" :title="convertToReadableText(item.value)"></v-list-item>
    </template>
</v-select>

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.