Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144841 | May 24,2019 08:39 PM UTC | May 27,2019 10:38 AM UTC | Vue | 1 |
![]() |
Tags: Data Grid |
Parent Component:
<template>
<ejs-grid ref='grid' id='Grid' :actionBegin='actionBegin' :editSettings='editSettings' :toolbar='toolbar' :dataSource="localData" :allowPaging="true">
...
</ejs-grid>
</template>
<script>
import Vue from 'vue';
import vueColumnTemplate from "./columntemplate.vue"
import { GridPlugin, Page, Edit, Toolbar } from '@syncfusion/ej2-vue-grids';
import { data } from '../datasource.js';
Vue.use(GridPlugin);
Vue.prototype.$eventHub = new Vue();
export default {
provide: {
grid: [ Page, Edit, Toolbar ]
},
data() {
return {
customerID: ""
}
},
methods: {
editTemplate: function() {
return {
template: vueColumnTemplate,
};
},
actionBegin: function(args) {
if(args.requestType == "beginEdit") {
this.$eventHub.$on('CustomerID', this.getTemplateValue);
};
if(args.requestType == "save") {
args.data.CustomerID = this.customerID; // Changed the CustomerID value by using the global variable
}
},
getTemplateValue: function(e) {
this.customerID = e; // collected the dropdownlist selected value and stored it in global Vue variable
}
}
}
</script>
Child Component:
<template>
<div class="attribute-container">
<div class="row">
<ejs-dropdownlist :dataSource="options" :change='change' v-model="$data.data.CustomerID" :fields='fields'></ejs-dropdownlist>
</div>
</div>
</template>
<script>
import Vue from 'vue';
import { DropDownListPlugin } from "@syncfusion/ej2-vue-dropdowns";
Vue.use(DropDownListPlugin);
export default {
data() {
...
},
methods: {
change: function(args) { // dropdownlist change event
this.$eventHub.$emit("CustomerID", args.itemData.CustomerID); // emitted the event from child component
}
}
};
</script> |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.