Dear support,
I use a multiselect in a form, which works very well.
When I submit my form , the selected items from the multiselect are stored in my database.
Next, when I click an "edit" button of my page, it opens a dialog with a form which contains the multiselect.
Here, I would like to show in the multiselect every items that have been previsouly created ( but it must also show the rest of the list by clicking on the on the multiselect).
In fact, I would like to do a similar thing as I would do in a simple select element :
"<select id="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="vw">VW</option>
<option value="audi" selected>Audi</option>
</select>"
but with your multiselect elements :
<ejs-multiselect id='cars' ?? ></ejs-multiselect>Is it possible ?
Best regards,
|
<ejs-multiselect id="multiselect" :dataSource="sportsData" :fields="fields" placeholder="Select a game" :value="preValue"></ejs-multiselect>
export default Vue.extend({
data: function () {
return {
sportsData: [
{ Id: "game1", Game: "Badminton" },
{ Id: "game2", Game: "Football" },
{ Id: "game3", Game: "Tennis" },
{ Id: "game4", Game: "Hockey" },
{ Id: "game5", Game: "Cricket" },
{ Id: "game6", Game: "Basketball" },
],
fields: { text: "Game", value: "Id" },
preValue: ["game3", "game2"],
};
},
});
|
Thank you for your answer.
This works perfectly as long as I don't add a v-model.
This code works :
But this one does not work :
How can I do, because I need to bind the multiselect in my form and preselect value at the sal?
Moreover, I need to populate dynamically the preValue.
In my example I had to hardcode in order to test
How can I do to populate preValueUserType with dynamic datas ?
Here is my file.
|
<ejs-multiselect id="multiselect"
:dataSource="sportsData"
:fields="fields"
placeholder="Select a game"
v-model="form.ref_agenda_type_id"></ejs-multiselect> |
|
methods: {
updateValue: function (event) {
this.form.ref_agenda_type_id = ["game1", "game2"];
} |