search

Home  >  Q&A  >  body text

Prevent specific chips from being removed from combobox

I have these combobox chips but there is a problem deletable-chips

<v-combobox
    v-model="selectedCategories"
    :items="attributeCategories"
    item-text="name"
    item-value="id"
    label="Category"
    multiple
    chips
    clear-icon="mdi-close-circle"
    deletable-chips
    v-on:change="changeCategory(selectedCategories)"
></v-combobox>

Is there a way to prevent specific chips from being deleted? For example, not showing a delete button on a specific button? Assume that for Device and only Weather and Geo Location

are allowed to be deleted
P粉674757114P粉674757114337 days ago446

reply all(1)I'll reply

  • P粉354948724

    P粉3549487242024-02-04 12:51:35

    Instead of using the v-chips built-in deletion method. You can do this by customizing the @click:close event. I created a working demo for you:

    new Vue({
      el: '#app',
      vuetify: new Vuetify(),
      data: () => ({
        model: [],
        items: [
          {
            text: 'Weather'
          },
          {
            text: 'Geo Location'
          },
          {
            text: 'Device'
          }
        ]
      }),
      methods: {
        remove (itemText) {
          if (itemText === 'Device') {
            return;
          } else {
            this.model.forEach(obj => {
              if (obj.text === itemText) {
                this.model.splice(this.model.indexOf(obj), 1)
              }
            })
            this.model = [...this.model]
          }
        }
      }
    })
    sssccc
    sssccc
    
    
    

    reply
    0
  • Cancelreply