Skip to content

Commit 0f94315

Browse files
authored
Merge pull request #1 from NilubaJashanaS/master
Adding vue dropdown tree sample
2 parents 90889da + 8d6084e commit 0f94315

File tree

10 files changed

+262
-1
lines changed

10 files changed

+262
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
# getting-started-with-the-vue-dropdown-tree-component
1+
# Getting Started with the Vue DropDown Tree Component
2+
23
A quick-start project that shows how to configure the dropdown tree component to a Vue app. This project includes a code snippet for binding JSON and Remote data sources to the component. It also includes a code snippet for selecting multiple items using checkboxes.
4+
5+
Refer to the following documentation to learn about the Vue DropDown Tree component:
6+
https://ej2.syncfusion.com/vue/documentation/drop-down-tree/vue-3-getting-started
7+
8+
Check out this online example of the Vue DropDown Tree component:
9+
https://ej2.syncfusion.com/vue/demos/#/material/drop-down-tree/default.html
10+
11+
## Project prerequisites
12+
Make sure that you have the compatible versions of [Visual Studio Code](https://code.visualstudio.com/download ) and [NodeJS](https://nodejs.org/en/download) or later version in your machine before starting to work on this project.
13+
14+
## How to run this application
15+
To run this application, you need to first clone the `getting-started-with-the-vue-dropdown-tree-component` repository and then open it in Visual Studio Code. Now, simply build and run your project to view the output.

index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<!-- <link href="https://cdn.syncfusion.com/ej2/22.1.34/material3.css" rel="stylesheet"> -->
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>Vite + Vue</title>
9+
</head>
10+
<body>
11+
<div id="app"></div>
12+
<script type="module" src="/src/main.js"></script>
13+
</body>
14+
</html>

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "myvueapp",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vite build",
9+
"preview": "vite preview"
10+
},
11+
"dependencies": {
12+
"@syncfusion/ej2-vue-dropdowns": "^23.2.7",
13+
"vue": "^3.3.8"
14+
},
15+
"devDependencies": {
16+
"@vitejs/plugin-vue": "^4.5.0",
17+
"vite": "^5.0.0"
18+
}
19+
}

public/vite.svg

Lines changed: 1 addition & 0 deletions
Loading

src/App.vue

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
<script >
3+
import { DropDownTreeComponent } from "@syncfusion/ej2-vue-dropdowns";
4+
import { DataManager,Query,ODataV4Adaptor } from "@syncfusion/ej2-data";
5+
var remoteData = new DataManager({
6+
url: 'https://services.odata.org/V4/Northwind/Northwind.svc',
7+
adaptor: new ODataV4Adaptor,
8+
crossDomain: true,
9+
});
10+
var dataQuery = new Query().from('Employees').select('EmployeeID,FirstName,Title').take(5);
11+
var childDataQuery = new Query().from('Orders').select('OrderID,EmployeeID,ShipName').take(5);
12+
var LocalData = [
13+
{ id: '01', name: 'Local Disk (C:)', expanded : true,
14+
subChild: [
15+
{ id: '01-01', name: 'Program Files', expanded : true,
16+
subChild: [
17+
{ id: '01-01-01', name: '7-Zip' },
18+
{ id: '01-01-02', name: 'Git' },
19+
{ id: '01-01-03', name: 'IIS Express' }
20+
]
21+
},
22+
{ id: '01-02', name: 'Users', expanded : true,
23+
subChild: [
24+
{ id: '01-02-01', name: 'Smith' },
25+
{ id: '01-02-02', name: 'Admin' }
26+
]
27+
},
28+
{ id: '01-03', name: 'Windows',
29+
subChild: [
30+
{ id: '01-03-01', name: 'FileManager' }
31+
]
32+
}
33+
]
34+
},
35+
{ id: '02', name: 'Local Disk (D:)',
36+
subChild: [
37+
{ id: '02-01', name: 'Personals' },
38+
{ id: '02-02', name: 'Projects' }
39+
]
40+
},
41+
{ id: '03', name: 'Local Disk (E:)',
42+
subChild: [
43+
{ id: '03-01', name: 'Pictures' },
44+
{ id: '03-02', name: 'Documents' }
45+
]
46+
}
47+
48+
49+
];
50+
export default {
51+
components: {
52+
'ejs-dropdowntree': DropDownTreeComponent
53+
},
54+
data (){
55+
return {
56+
fields: { dataSource: LocalData, value: 'id', text: 'name', child: 'subChild'},
57+
remoteDataFields: { dataSource: remoteData, query:dataQuery, value: 'EmployeeID', text: 'FirstName', hasChildren: 'EmployeeID',
58+
child: { dataSource: remoteData, query:childDataQuery, value: 'OrderID', parentValue: 'EmployeeID', text: 'ShipName' }},
59+
treeSettings:{autoCheck:true}
60+
}
61+
}
62+
}
63+
64+
65+
66+
</script>
67+
<template>
68+
<ejs-dropdowntree :fields='remoteDataFields' placeholder="Select a folder" popupHeight='200px'
69+
allowMultiSelection='true' showCheckBox='true' :treeSettings='treeSettings'
70+
71+
></ejs-dropdowntree>
72+
73+
</template>
74+
<style>
75+
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
76+
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
77+
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
78+
@import "../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material.css";
79+
</style>

src/assets/vue.svg

Lines changed: 1 addition & 0 deletions
Loading

src/components/HelloWorld.vue

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<script setup>
2+
import { ref } from 'vue'
3+
4+
defineProps({
5+
msg: String,
6+
})
7+
8+
const count = ref(0)
9+
</script>
10+
11+
<template>
12+
<h1>{{ msg }}</h1>
13+
14+
<div class="card">
15+
<button type="button" @click="count++">count is {{ count }}</button>
16+
<p>
17+
Edit
18+
<code>components/HelloWorld.vue</code> to test HMR
19+
</p>
20+
</div>
21+
22+
<p>
23+
Check out
24+
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
25+
>create-vue</a
26+
>, the official Vue + Vite starter
27+
</p>
28+
<p>
29+
Install
30+
<a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a>
31+
in your IDE for a better DX
32+
</p>
33+
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
34+
</template>
35+
36+
<style scoped>
37+
.read-the-docs {
38+
color: #888;
39+
}
40+
</style>

src/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createApp } from 'vue'
2+
import './style.css'
3+
import App from './App.vue'
4+
import {registerLicense} from '@syncfusion/ej2-base';
5+
registerLicense("Ngo9BigBOggjHTQxAR8/V1NHaF5cXmVCf1FpRGdGfV5yd0VHYlZRQXxcR00SNHVRdkdgWH5fdHRVRmVfV0FwX0o=");
6+
7+
8+
createApp(App).mount('#app')

src/style.css

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
:root {
2+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3+
line-height: 1.5;
4+
font-weight: 400;
5+
6+
color-scheme: light dark;
7+
color: rgba(255, 255, 255, 0.87);
8+
background-color: #242424;
9+
10+
font-synthesis: none;
11+
text-rendering: optimizeLegibility;
12+
-webkit-font-smoothing: antialiased;
13+
-moz-osx-font-smoothing: grayscale;
14+
}
15+
16+
a {
17+
font-weight: 500;
18+
color: #646cff;
19+
text-decoration: inherit;
20+
}
21+
a:hover {
22+
color: #535bf2;
23+
}
24+
25+
body {
26+
margin: 0;
27+
display: flex;
28+
place-items: center;
29+
min-width: 320px;
30+
min-height: 100vh;
31+
}
32+
33+
h1 {
34+
font-size: 3.2em;
35+
line-height: 1.1;
36+
}
37+
38+
button {
39+
border-radius: 8px;
40+
border: 1px solid transparent;
41+
padding: 0.6em 1.2em;
42+
font-size: 1em;
43+
font-weight: 500;
44+
font-family: inherit;
45+
background-color: #1a1a1a;
46+
cursor: pointer;
47+
transition: border-color 0.25s;
48+
}
49+
button:hover {
50+
border-color: #646cff;
51+
}
52+
button:focus,
53+
button:focus-visible {
54+
outline: 4px auto -webkit-focus-ring-color;
55+
}
56+
57+
.card {
58+
padding: 2em;
59+
}
60+
61+
#app {
62+
max-width: 1280px;
63+
margin: 0 auto;
64+
padding: 2rem;
65+
text-align: center;
66+
}
67+
68+
@media (prefers-color-scheme: light) {
69+
:root {
70+
color: #213547;
71+
background-color: #ffffff;
72+
}
73+
a:hover {
74+
color: #747bff;
75+
}
76+
button {
77+
background-color: #f9f9f9;
78+
}
79+
}

vite.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'vite'
2+
import vue from '@vitejs/plugin-vue'
3+
4+
// https://vitejs.dev/config/
5+
export default defineConfig({
6+
plugins: [vue()],
7+
})

0 commit comments

Comments
 (0)