Two-way-binding example is not working on DropDownList

This example is not loading https://ej2.syncfusion.com/vue/documentation/drop-down-list/two-way-binding/#two-way-binding

And I am facing some trouble making two-way-binding work with objects. So I need a working example to see if I'm doing something wrong.

Could anyone help me?


3 Replies 1 reply marked as answer

SP Sureshkumar P Syncfusion Team September 5, 2022 11:21 AM UTC

Hi Mauro,

As per your request, we have created the sample with V-model binding. Please find the sample in the attachment:

Find the code example here:

<template>

  <div>

  <p>V-model value {{value}}</p>

    <h1>dropdownlist component</h1>

    <ejs-dropdownlist

      id="dropdownlist"

      :dataSource="sportsData"

      placeholder="select value"

      :allowFiltering="true"

      v-model="value"

    ></ejs-dropdownlist>

  </div>

</template>

 

<script>

import { DropDownListComponent } from "@syncfusion/ej2-vue-dropdowns";

export default {

  name: "HelloWorld",

  components: {

    "ejs-dropdownlist": DropDownListComponent,

  },

  data() {

    return {

      value: null,

      sportsData: ["Badminton", "Cricket", "Football", "Golf", "Tennis"],

    };

  }

};

</script>

 

<!-- Add "scoped" attribute to limit CSS to this component only -->

<style>

@import "@syncfusion/ej2-base/styles/material.css";

@import "@syncfusion/ej2-inputs/styles/material.css";

@import "@syncfusion/ej2-vue-dropdowns/styles/material.css";

</style>

Note: If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.

Regards,

Sureshkumar P


Attachment: VModelddl_4b9bfcd3.zip


MG Mauro Gesuitti September 5, 2022 12:05 PM UTC

Hi Sureshkumar P, I downloaded the example. I tried to change the initial value to any option. For example,

value: "Badminton",


and the dropdown did not pre-select the value as expected.





SP Sureshkumar P Syncfusion Team September 6, 2022 09:49 AM UTC

Hi Mauro,

We suggest you use the v-model:value instead of v-model when preselecting the value to the component.

Find the modified code example here:

<template>

  <div>

  <p>V-model value {{value}}</p>

    <h1>dropdownlist component</h1>

    <ejs-dropdownlist

      id="dropdownlist"

      :dataSource="sportsData"

      placeholder="select value"

      :allowFiltering="true"

      v-model:value="value"

    ></ejs-dropdownlist>

  </div>

</template>

Regards,

Sureshkumar P


Marked as answer
Loader.
Up arrow icon