...
Vue.use(GridPlugin);
Vue.prototype.$eventHub = new Vue();
new Vue({
el: '#app',
template: `
<div id="app">
<ejs-grid id='grid' ref='grid' :dataSource="data" :allowPaging="true" :queryCellInfo='info' :pageSettings='pageSettings'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' minWidth= 100 width=150 maxWidth=250 ></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=120></e-column>
<e-column field='Freight' headerText='Freight' width=80></e-column>
<e-column headerText='columnTemplate' width='150' textAlign='Center' :template='cTemplate'></e-column>
</e-columns>
</ejs-grid>
</div>
`,
data() {
return {
data: [
...
],
cTemplate: function () {
return {
template: Vue.component('columnTemplate',{
template: `<button v-on:click="fun(event)">buttton</button>`,
data: function(){
return {
data:{},
usernameTemplate:""
}
},
created() {
this.$eventHub.$on('detail', (e)=>{ //listen emitted values in other component
this.usernameTemplate =e;
});
},
methods: {
fun: function(e){
console.log("passed value: "+ this.usernameTemplate);
}
}
})
}
},
...
};
},
methods: {
info: function(args) {
this.$eventHub.$emit('detail',this.username); //emit event
}
},
provide: {
grid: [Page]
}
}); |