|
<template>
<div id="app">
<div>
<ejs-grid ref="grid" :toolbar="toolbar" id="grid" :editSettings="editSettings" :dataSource="data" :actionComplete="actionComplete">
<e-columns>
<e-column
field="OrderID"
headerText="Order ID"
textAlign="Right"
:isPrimaryKey="true"
width="100"
></e-column>
<e-column field="CustomerID" headerText="Customer ID" width="120"></e-column>
<e-column field="Freight" editType='numericedit' headerText="Freight" textAlign="Right" width="120" format="C2"></e-column>
</e-columns>
</ejs-grid>
</div>
</div>
</template>
<script>
import Vue from "vue";
import { GridPlugin, Page, Edit,Toolbar } from "@syncfusion/ej2-vue-grids";
import { ButtonPlugin } from "@syncfusion/ej2-vue-buttons";
import {gridData} from './data'
Vue.use(ButtonPlugin);
Vue.use(GridPlugin);
export default {
data() {
return {
data: gridData,
toolbar: ['Add', 'Update', 'Delete', 'Cancel'],
editSettings: {allowAdding: true, allowEditing: true, allowDeleting: true},
};
},
methods: {
actionComplete: function(args) {
if (args.requestType === "beginEdit" ||
args.requestType === "add" ) {
// here we can get the input element for corresponding fieldname
var inputEle = args.form.elements.namedItem('CustomerID');
// here we can apply the maxlength for the input
inputEle.maxLength = 5;
}
}
},
provide: {
grid: [Page, Edit, Toolbar]
}
};
</script>
|