lundi 27 juin 2022

How to uncheck V-Checkbox by default, if the V-model is an array

Within a Salesforce Visualforce Apex Page, I have a V-Flex. Within it a row of V-Checkboxes is created dynamically. Like this:

<v-flex v-for="cluster in getCluster" v-bind:key="cluster.clusterName">
    <v-checkbox v-model="selectedCluster" v-bind:label="cluster.clusterName" v-bind:color="cluster.clusterColor" v-bind:value="cluster.clusterName" v-on:change="displayData"> 
  </v-checkbox>
</v-flex>

getCluster provides data like this:

let clusterData = [];
clusterData.push({ clusterName: 'A', clusterColor: 'red' });
[...]
clusterData.push({ clusterName: 'Z', clusterColor: 'blue' });

selectedCluster is an array containing, all the names/values of the checkboxes like this: ['A', [...], 'Z']

This results in a page, where at first all boxes are checked and you can filter out values from a set of data by unchecking the corresponding box. My Goal now is to disable some of the checkboxes, but not all, while keeping their functually intact, i.e. if a box is unchecked by default, then its respective data should be filtered out by default as well.

I have tried many things, like changing the v-bind:value or v-model but all of my attempts have either not changed the checked state of the checkbox, or have disabled the boxes functionality. I have also tried adding input-value="false", as described here or only having either v-model or v-bind:value, as desribed here, but neither if these have produced the desired outcome.




Aucun commentaire:

Enregistrer un commentaire