dropdownTemplate: function () {
return {
template: Vue.component('bindDropdown', {
template: `<ejs-dropdownlist id='dropdownlist' :value='dropdownInitialData' :dataSource='dropData'> </ejs-dropdownlist>`,
data: function() {
return {
dropData: ['VINET', 'TOMSP', 'HANAR', 'VICTE', 'SUPRD', 'HANAR', 'CHOPS', 'RICSU'],
}
},
computed: {
dropdownInitialData: function(e) {
return this._data.data.CustomerID;
}
}
})
}
} |
import HelloWorld2 from './HelloWorld2.vue';
myComponentTemplate: function () {
return {
template: HelloWorld2
}
} |
[HelloWorld2.Vue]
<template>
<div class="hello" id="hello">
<p>{{msg}}</p>
<button v-on:click="Click">Add 1</button>
</div>
</template>
<script>
export default {
name: 'HelloWorld2',
props: {
msg: {type:String, default:"HelloWord2"},
},
methods:{
Click(args){
alert("click triggered"+ this.$props.msg) //Accessed the props
}
}
}
</script>
|
<template>
<div class="hello" id="hello">
<button v-on:click="Click">{{idData}}</button>
</div>
</template>
<script>
export default {
name: 'HelloWorld2',
data() {
return {
// Define the variable for accessing current row data
data: {},
};
},
computed: {
idData: function() {
...
}
},
methods:{
// Button’s click event function
Click(args){
alert("Customer ID - "+ this.data.CustomerID) // Accessed the row data
}
}
} |
How would you do this for Vue 3?
<template>
<div id="app">
<ejs-grid :dataSource='data' :allowPaging="true">
<e-columns>
. . . . . . . . .
. . . . . . . . .
<e-column headerText='Employee Image' width='150' textAlign='Center' :template='colTemplate'></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
import { GridComponent, ColumnsDirective, ColumnDirective, Page } from '@syncfusion/ej2-vue-grids';
import { createApp } from "vue";
const app = createApp();
// Template declaration
var colVue = app.component("colTemplate", {
data() {
return {
data: {},
};
},
computed: {
idData: function() {
return this.data.OrderID;
}
},
methods:{
Click(){
alert("Customer ID - "+ this.data.CustomerID) //Accessed the row data
}
},
template: `<button v-on:click="Click">{{idData}}</button> `,
});
export default {
name: 'App',
components: {
// Register Component
'ejs-grid' : GridComponent,
'e-columns' : ColumnsDirective,
'e-column' : ColumnDirective
},
data() {
return {
data: [
{
"OrderID":10248,
"CustomerID":"VINET",
"ShipCountry":"France"
},
{
"OrderID":10249,
"CustomerID":"TOMSP",
"ShipCountry":"Germany"
}],
colTemplate: function () {
return { template: colVue };
}
};
},
// module injection
provide: {
grid: [Page],
}
};
</script>
<style>
</style>
|