Skip to content

Commit 6c2dfca

Browse files
authored
Committed the example project.
0 parents  commit 6c2dfca

File tree

10 files changed

+11934
-0
lines changed

10 files changed

+11934
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Customize ComboBox Items Using Templates
2+
3+
Learn how easily you can customize the Syncfusion Vue ComboBox items using templates. You will learn how to customize the Syncfusion Vue ComboBox items. You will see how to add a header and footer for the ComboBox pop-up, and how to customize the ComboBox group title.
4+
5+
Example: https://ej2.syncfusion.com/vue/documentation/combo-box/templates
6+
Documentation: https://ej2.syncfusion.com/vue/demos/#/material/combo-box/template.html
7+
8+
9+
## Project pre-requisites
10+
Make sure that you have the compatible versions of Node and Vue-Cli in your machine before starting to work on this project.
11+
12+
## How to run this application?
13+
To run this application, you need to first clone the `customize-combo-box-items-using-templates` repository and then navigate to its appropriate path where it has been located in your system.
14+
15+
To do so, open the command prompt and run the below commands one after the other.
16+
17+
```
18+
git clone https://github.com/SyncfusionExamples/customize-combo-box-items-using-templates combobox-component
19+
cd combobox-component
20+
```
21+
22+
## Installing
23+
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.
24+
25+
```
26+
npm install
27+
```
28+
29+
## Running on development server
30+
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.
31+
32+
## Further help
33+
34+
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

Lines changed: 5 additions & 0 deletions
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-lock.json

Lines changed: 11616 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "combo-box",
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-dropdowns": "^17.3.27",
12+
"core-js": "^3.3.2",
13+
"vue": "^2.6.10"
14+
},
15+
"devDependencies": {
16+
"@vue/cli-plugin-babel": "^4.0.0",
17+
"@vue/cli-plugin-eslint": "^4.0.0",
18+
"@vue/cli-service": "^4.0.0",
19+
"babel-eslint": "^10.0.3",
20+
"eslint": "^5.16.0",
21+
"eslint-plugin-vue": "^5.0.0",
22+
"vue-template-compiler": "^2.6.10"
23+
},
24+
"eslintConfig": {
25+
"root": true,
26+
"env": {
27+
"node": true
28+
},
29+
"extends": [
30+
"plugin:vue/essential",
31+
"eslint:recommended"
32+
],
33+
"rules": {},
34+
"parserOptions": {
35+
"parser": "babel-eslint"
36+
}
37+
},
38+
"postcss": {
39+
"plugins": {
40+
"autoprefixer": {}
41+
}
42+
},
43+
"browserslist": [
44+
"> 1%",
45+
"last 2 versions"
46+
]
47+
}

public/favicon.ico

4.19 KB
Binary file not shown.

public/index.html

Lines changed: 17 additions & 0 deletions
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>combo-box</title>
9+
</head>
10+
<body>
11+
<noscript>
12+
<strong>We're sorry but combo-box 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

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<template>
2+
<div>
3+
<div style="margin:10% 40%; width:250px">
4+
5+
<!-- ItemTemplate, HeaderTemplate, FooterTemplate Code Snippet -->
6+
<!-- <ejs-combobox :dataSource='dataItem'
7+
:fields='dataFields' placeholder='Select a platform'
8+
:itemTemplate='comboboxItemTemplate'
9+
:headerTemplate='comboboxHeaderTemplate'
10+
:footerTemplate='comboboxFooterTemplate'>
11+
</ejs-combobox> -->
12+
13+
<!-- GroupTemplate Code Snippet -->
14+
<ejs-combobox
15+
:dataSource='dataItem' :fields='dataFields' placeholder='Select a name'
16+
:groupTemplate="comboboxGroupTemplate">
17+
</ejs-combobox>
18+
</div>
19+
</div>
20+
</template>
21+
22+
<script>
23+
import Vue from 'vue';
24+
import { ComboBoxPlugin } from "@syncfusion/ej2-vue-dropdowns";
25+
Vue.use(ComboBoxPlugin);
26+
27+
export default Vue.extend({
28+
data: function() {
29+
return {
30+
31+
// GroupTemplate Code Snippet
32+
comboboxGroupTemplate:"<b><i>${Country}</i></b>",
33+
dataItem: [
34+
{EmployeeID:1,EmployeeName:"Anne Dodsworth",Country:"USA"},
35+
{EmployeeID:2,EmployeeName:"Janet Leverling",Country:"USA"},
36+
{EmployeeID:3,EmployeeName:"Margaret Peacock",Country:"USA"},
37+
{EmployeeID:4,EmployeeName:"Robert King",Country:"England"},
38+
{EmployeeID:5,EmployeeName:"Steven Buchanan",Country:"England"}],
39+
40+
dataFields: { text: 'EmployeeName', value: 'EmployeeId', groupBy: 'Country' }
41+
42+
// ItemTemplate, HeaderTemplate, FooterTemplate Code Snippet
43+
// comboboxItemTemplate:"<div class='list-wrapper'><span class= '${Image} e-avatar'></span><span class='text'>${Name}</span></div>",
44+
// comboboxHeaderTemplate:"<span class='header'><span class='img'>Photo</span><span class='name'>Platform</span></span>",
45+
// comboboxFooterTemplate:"<span class='footer'> Total list item: 5</span>",
46+
// dataItem: [
47+
// { Name: "JavaScript", Id: "item1", Image: "javascript" },
48+
// { Name: "TypeScript", Id: "item2", Image: "typescript" },
49+
// { Name: "Angular", Id: "item3", Image: "angular" },
50+
// { Name: "React", Id: "item4", Image: "react" },
51+
// { Name: "Vue", Id: "item5", Image: "vue" }
52+
// ],
53+
// dataFields: { text: 'Name', value: 'Id' }
54+
};
55+
}
56+
});
57+
</script>
58+
59+
60+
<style>
61+
@import url(https://cdn.syncfusion.com/ej2/material.css);
62+
63+
/* CSS styles for ItemTemplate, HeaderTemplate, FooterTemplate */
64+
65+
/* .list-wrapper {
66+
height: inherit;
67+
position: relative;
68+
padding: 14px 12px 14px 78px;
69+
}
70+
71+
.list-wrapper .text {
72+
display: block;
73+
margin: 0;
74+
padding-bottom: 3px;
75+
white-space: normal;
76+
font-size: 13px;
77+
}
78+
79+
.list-wrapper .e-avatar {
80+
position: absolute;
81+
left: 5px;
82+
background-color: transparent;
83+
font-size: 22px;
84+
top: calc(50% - 33px);
85+
}
86+
87+
.typescript {
88+
background-image: url('https://ej2.syncfusion.com/products/images/list-box/javascript1.svg');
89+
}
90+
91+
.javascript {
92+
background-image: url('https://ej2.syncfusion.com/products/images/list-box/jses5-1.svg');
93+
}
94+
95+
.angular {
96+
background-image: url('https://ej2.syncfusion.com/products/images/list-box/angular1.svg');
97+
}
98+
99+
.vue {
100+
background-image: url('https://ej2.syncfusion.com/products/images/list-box/vue.svg');
101+
}
102+
103+
.react {
104+
background-image: url('https://ej2.syncfusion.com/products/images/list-box/react.svg');
105+
}
106+
107+
108+
.header,
109+
.list-wrapper {
110+
display: table;
111+
width: 100%;
112+
margin: auto;
113+
}
114+
115+
.header {
116+
height: 40px;
117+
font-size: 15px;
118+
font-weight: 600;
119+
}
120+
121+
.name,
122+
.img {
123+
display: table-cell;
124+
vertical-align: middle;
125+
}
126+
.name {
127+
width: 70%;
128+
}
129+
130+
.img {
131+
width: 30%;
132+
}
133+
134+
.header .name {
135+
text-indent: 15px;
136+
}
137+
138+
.header .img {
139+
text-indent: 8px;
140+
}
141+
142+
.footer {
143+
text-indent: 1.2em;
144+
display: block;
145+
font-size: 15px;
146+
line-height: 40px;
147+
border-top: 1px solid #e0e0e0;
148+
} */
149+
</style>

src/assets/logo.png

6.69 KB
Loading

src/components/HelloWorld.vue

Lines changed: 58 additions & 0 deletions
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

Lines changed: 8 additions & 0 deletions
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)