Skip to content

Added Vue Dropdown List Sample #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,35 @@
# create-cascading-dropdown-list-using-vue-dropdown-list
A quick start Vue project that helps you to learn how to create a Cascading Dropdown List using Vue Dropdown List of Syncfusion.
# Create a Cascading Dropdown List Using Vue Dropdown List

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.

Example: https://ej2.syncfusion.com/vue/demos/#/material/drop-down-list/cascading.html

Documentation: https://ej2.syncfusion.com/vue/documentation/drop-down-list/how-to/cascading


## Project pre-requisites
Make sure that you have the compatible versions of Node and Vue-Cli in your machine before starting to work on this project.

## How to run this application?
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.

To do so, open the command prompt and run the below commands one after the other.

```
git clone https://github.com/SyncfusionExamples/create-a-cascading-dropdown-list-using-vue-dropdown-list dropdownlist-component
cd dropdownlist-component
```

## Installing
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.

```
npm install
```

## Running on development server
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.

## Further help

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).
5 changes: 5 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
48 changes: 48 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "dropdownlist-component",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@syncfusion/ej2-vue-buttons": "^17.3.27",
"@syncfusion/ej2-vue-dropdowns": "^17.3.21",
"core-js": "^3.3.2",
"vue": "^2.6.10"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.0.0",
"@vue/cli-plugin-eslint": "^4.0.0",
"@vue/cli-service": "^4.0.0",
"babel-eslint": "^10.0.3",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"vue-template-compiler": "^2.6.10"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}
Binary file added public/favicon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>dropdownlist-component</title>
</head>
<body>
<noscript>
<strong>We're sorry but dropdownlist-component doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
53 changes: 53 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<template>
<div style="margin:10% 40%; width:250px;">
<div id="dropdownlist_country">
<ejs-dropdownlist :dataSource='dataItem' :fields='dataFields'
placeholder='Select a country' :change='onCountryChange'
ref='dropdownInstance'>
</ejs-dropdownlist>
<div id="dropdownlist_state" style="padding-top:20px;">
<ejs-dropdownlist :dataSource='stateDataItem' :fields='stateDataFields'
placeholder='Select a state' :enabled='enableDropdown'
:query='childDataQuery'>
</ejs-dropdownlist>
</div>
</div>
</div>
</template>

<script>
import Vue from 'vue';
import { DropDownListPlugin } from "@syncfusion/ej2-vue-dropdowns";
import { Query } from "@syncfusion/ej2-data";
Vue.use(DropDownListPlugin);

export default Vue.extend({
data: function() {
return {
enableDropdown: false,
childDataQuery: null,
dataItem: [
{ CountryName: 'United States', CountryId: '1' },
{ CountryName: 'Australia', CountryId: '2' }
],
dataFields: { text: 'CountryName', value: 'CountryId' },
stateDataItem: [
{ StateName: 'New York', StateId: '101', CountryId: '1' },
{ StateName: 'Virginia ', StateId: '102', CountryId: '1' },
{ StateName: 'Tasmania ', StateId: '105', CountryId: '2' }
],
stateDataFields: { text: 'StateName', value: 'StateId'},
};
},
methods: {
onCountryChange: function(args) {
this.enableDropdown = true;
this.childDataQuery = new Query().where('CountryId', 'equal', args.value);
}
}
});
</script>

<style>
@import url(https://cdn.syncfusion.com/ej2/material.css);
</style>
Binary file added src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>

<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
8 changes: 8 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Vue from 'vue'
import App from './App.vue'

Vue.config.productionTip = false

new Vue({
render: h => h(App),
}).$mount('#app')