|
| 1 | + |
| 2 | +<template> |
| 3 | + <div style="margin:10% 40%; width:250px;"> |
| 4 | + <div> |
| 5 | + <ejs-combobox :dataSource='dataItem' :fields='dataFields' |
| 6 | + placeholder='Select a country' :change='onCountryChange' |
| 7 | + ref='comboboxInstance'> |
| 8 | + </ejs-combobox> |
| 9 | + </div> |
| 10 | + <div style="padding-top:20px;"> |
| 11 | + <ejs-combobox :dataSource='stateDataItem' :fields='stateDataFields' |
| 12 | + placeholder='Select a state' :enabled='enableCombobox' |
| 13 | + :query='childDataQuery'> |
| 14 | + </ejs-combobox> |
| 15 | + </div> |
| 16 | + </div> |
| 17 | +</template> |
| 18 | + |
| 19 | +<script> |
| 20 | +import Vue from "vue"; |
| 21 | +import { ComboBoxPlugin} from '@syncfusion/ej2-vue-dropdowns'; |
| 22 | +import { Query } from "@syncfusion/ej2-data"; |
| 23 | +Vue.use(ComboBoxPlugin); |
| 24 | +
|
| 25 | +export default Vue.extend({ |
| 26 | + data: function() { |
| 27 | + return { |
| 28 | + enableCombobox: false, |
| 29 | + childDataQuery: null, |
| 30 | + dataItem: [ |
| 31 | + { CountryName: 'United States', CountryId: '1' }, |
| 32 | + { CountryName: 'Australia', CountryId: '2' } |
| 33 | + ], |
| 34 | + dataFields: { text: 'CountryName', value: 'CountryId' }, |
| 35 | + stateDataItem: [ |
| 36 | + { StateName: 'New York', StateId: '101', CountryId: '1' }, |
| 37 | + { StateName: 'Virginia ', StateId: '102', CountryId: '1' }, |
| 38 | + { StateName: 'Tasmania ', StateId: '105', CountryId: '2' } |
| 39 | + ], |
| 40 | + stateDataFields: { text: 'StateName', value: 'StateId'}, |
| 41 | + }; |
| 42 | + }, |
| 43 | + methods: { |
| 44 | + onCountryChange: function(args) { |
| 45 | + this.enableCombobox = true; |
| 46 | + this.childDataQuery = new Query().where('CountryId', 'equal', args.value); |
| 47 | + } |
| 48 | + } |
| 49 | +}); |
| 50 | +</script> |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +<style> |
| 63 | +@import url(https://cdn.syncfusion.com/ej2/material.css); |
| 64 | +</style> |
0 commit comments