<template>
<div class="col-lg-12 control-section">
<ejs-grid ref="grid" id="grid" :dataSource="data" :allowPaging="true" :editSettings="editSettings" :toolbar="toolbar" :actionBegin="actionBegin" :load="load" :queryCellInfo="queryCellInfo">
...
<e-column field="OrderDate" headerText="Order Date" textAlign="Right" :editTemplate="editTemplate" format="yMd" type="date" width="120"></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
...
import { Internationalization } from "@syncfusion/ej2-base";
Vue.use(GridPlugin);
Vue.use(DateRangePickerPlugin);
var initial;
export default Vue.extend({
data: () => {
return {
...
editTemplate: function() {
return {
template: Vue.component("datePicker", {
template: `<ejs-daterangepicker format="d/M" v-model="data.OrderDate"></ejs-daterangepicker>`,
data() {
return { data: {} };
}
})
};
},
toolbar: ["Add", "Edit", "Delete", "Update", "Cancel"]
};
},
methods: {
actionBegin: function(args) {
if (args.requestType === "save") {
args.data.OrderDate = document.getElementsByClassName(
"e-daterangepicker"
)[0].value;
initial = true;
}
},
queryCellInfo: function(args) {
if (args.column.field === "OrderDate") {
if (!initial) {
let intl = new Internationalization();
let d1 = intl.formatDate(new Date(args.data.OrderDate[0]), {
format: "d/M"
});
let d2 = intl.formatDate(new Date(args.data.OrderDate[1]), {
format: "d/M"
});
var date = d1 + "-" + d2;
args.cell.innerHTML = date; //render date as required format at initial
} else {
args.cell.innerHTML = args.data.OrderDate; //render date after editing
}
}
},
load: function() {
initial = false;
}
},
...
});
</script> |
<template>
<div class="col-lg-12 control-section">
<ejs-grid ref="grid"
...
:queryCellInfo="queryCellInfo">
<e-columns>
...
</e-columns>
</ejs-grid>
</div>
</template>
<script>
...
export default Vue.extend({
data: () => {
return {
dateValue: "",
data: data.slice(0, 20),
editSettings: {
allowEditing: true,
allowAdding: true,
allowDeleting: true
},
editTemplate: function() {
return {
template: Vue.component("datePicker", {
template: `<ejs-daterangepicker format="d/M" v-model="data.OrderDate"></ejs-daterangepicker>`,
data() {
return { data: {} };
}
})
};
},
toolbar: ["Add", "Edit", "Delete", "Update", "Cancel"]
};
},
methods: {
actionBegin: function(args) {
if (args.requestType === "save") {
args.data.OrderDate = document.getElementsByClassName(
"e-daterangepicker"
)[0].ej2_instances[0].value; //getting date values from daterangepicker instance. Previously we got value from element which is cause
}
},
queryCellInfo: function(args) {
if (args.column.field === "OrderDate") {
let intl = new Internationalization();
let d1 = intl.formatDate(new Date(args.data.OrderDate[0]), {
format: "d/M"
});
let d2 = intl.formatDate(new Date(args.data.OrderDate[1]), {
format: "d/M"
});
var date = d1 + "-" + d2;
args.cell.innerHTML = date;
}
}
},
computed: {},
provide: {
grid: [Toolbar, Edit, Page]
}
});
</script> |
<template>
<v-dialog v-model="editorShown" v-bind:retain-focus="false" persistentwidth="800">
<v-card id="voyageSettings1">
<v-card-text>
<v-container fluid grid-list-lg>
<v-layout wrap align-center>
<v-flex xs3 d-flex></v-flex>
<v-flex xs3 d-flex>
<ejs-daterangepicker
id="daterangepicker1"
format="d/M/y"
floatLabelType="Always"
placeholder="Laycan"
v-model="laycan"
></ejs-daterangepicker>
</v-flex> |