Skip to content

Commit 1f49344

Browse files
Merge pull request #1 from subaa1492/master
Added Vue Dropdown List Sample
2 parents 4dfa4c4 + 306b2a6 commit 1f49344

File tree

9 files changed

+224
-2
lines changed

9 files changed

+224
-2
lines changed

README.md

+35-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
1-
# create-cascading-dropdown-list-using-vue-dropdown-list
2-
A quick start Vue project that helps you to learn how to create a Cascading Dropdown List using Vue Dropdown List of Syncfusion.
1+
# Create a Cascading Dropdown List Using Vue Dropdown List
2+
3+
Get a quick overview on how to create a Cascading Dropdown List using Vue Dropdown List of Syncfusion. You will learn how to add a series of Syncfusion Vue DropDown List to the Vue application. Also, you will see how to populate the data source of second DropDown List based on the value selected from the first DropDown List.
4+
5+
Example: https://ej2.syncfusion.com/vue/demos/#/material/drop-down-list/cascading.html
6+
7+
Documentation: https://ej2.syncfusion.com/vue/documentation/drop-down-list/how-to/cascading
8+
9+
10+
## Project pre-requisites
11+
Make sure that you have the compatible versions of Node and Vue-Cli in your machine before starting to work on this project.
12+
13+
## How to run this application?
14+
To run this application, you need to first clone the `create-a-cascading-dropdown-list-using-vue-dropdown-list` repository and then navigate to its appropriate path where it has been located in your system.
15+
16+
To do so, open the command prompt and run the below commands one after the other.
17+
18+
```
19+
git clone https://github.com/SyncfusionExamples/create-a-cascading-dropdown-list-using-vue-dropdown-list dropdownlist-component
20+
cd dropdownlist-component
21+
```
22+
23+
## Installing
24+
Once done with downloading, next you need to install the necessary packages required to run this application locally. The `npm install` command will install all the needed Vue packages into your current project and to do so, run the below command.
25+
26+
```
27+
npm install
28+
```
29+
30+
## Running on development server
31+
Run `npm run serve` command for a dev server. Navigate to `http://localhost:8080/`. The app will automatically reload if you change any of the source files.
32+
33+
## Further help
34+
35+
To get more help on the vue CLI use go check out the [Vue-Cli README](https://github.com/vuejs/vue-cli/blob/master/README.md).

babel.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/cli-plugin-babel/preset'
4+
]
5+
}

package.json

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "dropdownlist-component",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"serve": "vue-cli-service serve",
7+
"build": "vue-cli-service build",
8+
"lint": "vue-cli-service lint"
9+
},
10+
"dependencies": {
11+
"@syncfusion/ej2-vue-buttons": "^17.3.27",
12+
"@syncfusion/ej2-vue-dropdowns": "^17.3.21",
13+
"core-js": "^3.3.2",
14+
"vue": "^2.6.10"
15+
},
16+
"devDependencies": {
17+
"@vue/cli-plugin-babel": "^4.0.0",
18+
"@vue/cli-plugin-eslint": "^4.0.0",
19+
"@vue/cli-service": "^4.0.0",
20+
"babel-eslint": "^10.0.3",
21+
"eslint": "^5.16.0",
22+
"eslint-plugin-vue": "^5.0.0",
23+
"vue-template-compiler": "^2.6.10"
24+
},
25+
"eslintConfig": {
26+
"root": true,
27+
"env": {
28+
"node": true
29+
},
30+
"extends": [
31+
"plugin:vue/essential",
32+
"eslint:recommended"
33+
],
34+
"rules": {},
35+
"parserOptions": {
36+
"parser": "babel-eslint"
37+
}
38+
},
39+
"postcss": {
40+
"plugins": {
41+
"autoprefixer": {}
42+
}
43+
},
44+
"browserslist": [
45+
"> 1%",
46+
"last 2 versions"
47+
]
48+
}

public/favicon.ico

4.19 KB
Binary file not shown.

public/index.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
8+
<title>dropdownlist-component</title>
9+
</head>
10+
<body>
11+
<noscript>
12+
<strong>We're sorry but dropdownlist-component doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
13+
</noscript>
14+
<div id="app"></div>
15+
<!-- built files will be auto injected -->
16+
</body>
17+
</html>

src/App.vue

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

src/assets/logo.png

6.69 KB
Loading

src/components/HelloWorld.vue

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<template>
2+
<div class="hello">
3+
<h1>{{ msg }}</h1>
4+
<p>
5+
For a guide and recipes on how to configure / customize this project,<br>
6+
check out the
7+
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
8+
</p>
9+
<h3>Installed CLI Plugins</h3>
10+
<ul>
11+
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
12+
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
13+
</ul>
14+
<h3>Essential Links</h3>
15+
<ul>
16+
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
17+
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
18+
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
19+
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
20+
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
21+
</ul>
22+
<h3>Ecosystem</h3>
23+
<ul>
24+
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
25+
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
26+
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
27+
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
28+
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
29+
</ul>
30+
</div>
31+
</template>
32+
33+
<script>
34+
export default {
35+
name: 'HelloWorld',
36+
props: {
37+
msg: String
38+
}
39+
}
40+
</script>
41+
42+
<!-- Add "scoped" attribute to limit CSS to this component only -->
43+
<style scoped>
44+
h3 {
45+
margin: 40px 0 0;
46+
}
47+
ul {
48+
list-style-type: none;
49+
padding: 0;
50+
}
51+
li {
52+
display: inline-block;
53+
margin: 0 10px;
54+
}
55+
a {
56+
color: #42b983;
57+
}
58+
</style>

src/main.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Vue from 'vue'
2+
import App from './App.vue'
3+
4+
Vue.config.productionTip = false
5+
6+
new Vue({
7+
render: h => h(App),
8+
}).$mount('#app')

0 commit comments

Comments
 (0)