Skip to content

Commit 3d22b4f

Browse files
authored
Merge pull request #1 from MeenaAlagiah/master
Adding the Vue Tab Data Binding sample
2 parents 456d759 + 46784b8 commit 3d22b4f

File tree

11 files changed

+176
-2
lines changed

11 files changed

+176
-2
lines changed

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
1-
# how-to-load-tab-items-from-a-remote-data-source-in-vue-tabs
2-
A quick start Vue project that shows how to bind JSON and Remote data sources to the Vue Tab Component.
1+
# How to Load Tab Items from a Remote Data Source in Vue Tabs
2+
A quick start Vue project that shows how to bind JSON and Remote data sources to the Vue Tabs Component.
3+
4+
Refer to the following documentation to learn about the Vue Tabs component:
5+
https://ej2.syncfusion.com/vue/documentation/tab/how-to/load-tab-with-data-source
6+
7+
Check out this online example of the Vue Tabs Component:
8+
https://ej2.syncfusion.com/vue/demos/#/material3/tab/default.html
9+
10+
Make sure that you have the latest versions of NodeJS and Visual Studio Code 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 clone the `how-to-load-tab-items-from-a-remote-data-source-in-vue-tabs` repository and then open it in Visual Studio Code. Now, simply install all the necessary vue packages into your current project using the `npm install` command and run your project using the `npm run dev` command.

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + Vue</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/main.js"></script>
12+
</body>
13+
</html>

package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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-buttons": "^22.2.8",
13+
"@syncfusion/ej2-vue-navigations": "^22.2.7",
14+
"@syncfusion/ej2-vue-popups": "^22.2.7",
15+
"vue": "^3.3.4"
16+
},
17+
"devDependencies": {
18+
"@vitejs/plugin-vue": "^4.2.3",
19+
"vite": "^4.4.5"
20+
}
21+
}

public/vite.svg

Lines changed: 1 addition & 0 deletions
Loading

src/App.vue

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<script setup>
2+
import { TabComponent as EjsTab, TabItemsDirective as ETabitems, TabItemDirective as ETabItem}
3+
from "@syncfusion/ej2-vue-navigations";
4+
import { DataManager, Query, ODataV4Adaptor } from "@syncfusion/ej2-data";
5+
const onCreate = function()
6+
{
7+
var obj = this.vueInstance.ej2Instances;
8+
9+
// JSON Data Source
10+
// const tabData = [
11+
// { header: "Steven", content: "Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree in 1976.Upon joining the company as a sales representative in 1992, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London.He was promoted to sales manager in March 1993.Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management.'He is fluent in French." },
12+
// { header: "Michael", content: "Michael is a graduate of Sussex University (MA, economics, 1983) and the University of California at Los Angeles (MBA, marketing, 1986).He has also taken the courses 'Multi-Cultural Selling' and 'Time Management for the Sales Professional.'He is fluent in Japanese and can read and write French, Portuguese, and Spanish." },
13+
// { header: "Robert", content: "Robert King served in the Peace Corps and traveled extensively before completing his degree in English at the University of Michigan in 1992, the year he joined the company.After completing a course entitled 'Selling in Europe,' he was transferred to the London office in March 1993." }
14+
// ]
15+
16+
//Remote Data Source
17+
new DataManager({ url:'https://services.odata.org/V4/Northwind/Northwind.svc/Employees',
18+
adaptor: new ODataV4Adaptor}).executeQuery(new Query().range(4,7))
19+
.then((e) => {
20+
var tabData = e.result;
21+
var fieldMapping = { header:'FirstName', content: 'Notes'}
22+
var tabItems = [];
23+
for(var i=0; i<tabData.length; i++)
24+
{
25+
tabItems.push({ header: {text: tabData[i][fieldMapping.header] },
26+
content: tabData[i][fieldMapping.content] });
27+
obj.items = tabItems;
28+
obj.refresh();
29+
}
30+
});
31+
}
32+
33+
</script>
34+
35+
<template>
36+
<ejs-tab cssClass="tab-content e-fill" width="850" :created="onCreate">
37+
</ejs-tab>
38+
</template>
39+
40+
<style>
41+
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
42+
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
43+
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
44+
@import "../node_modules/@syncfusion/ej2-vue-navigations/styles/material.css";
45+
46+
.tab-content .e-content .e-item {
47+
font-size: 12px;
48+
padding: 10px;
49+
text-align: justify;
50+
}
51+
</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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { createApp } from 'vue'
2+
import './style.css'
3+
import App from './App.vue'
4+
5+
createApp(App).mount('#app')

src/style.css

Whitespace-only changes.

0 commit comments

Comments
 (0)