Hi Team,
I am working on requirement where grid has to be loaded initially with empty row and need to always have an empty row at the bottom to add new items. I want to achieve this without using toolbar.
I am adding gif image for reference.
Thanks & Regards,
Sandeep G
|
[App.vue]
editSettings: {
allowEditing: true,
allowAdding: true,
allowDeleting: true,
newRowPosition: "Bottom",
},
|
|
[App.vue]
<template>
<div id="app">
<ejs-grid
ref="grid"
:dataSource="data"
:editSettings="editSettings"
:toolbar="toolbar"
:load="load"
:dataBound="dataBound"
:actionBegin="actionBegin"
:actionComplete="actionComplete"
height="273px"
>
----
</ejs-grid>
</div>
</template>
<script>
--
Vue.use(GridPlugin);
export default {
data() {
flag: false,
--
},
methods: {
load: function (args) {
this.flag = true;
},
dataBound: function (args) {
if (this.flag) {
// below code is executed only at initial render of Grid
this.flag = false;
var grid = this.$refs.grid.$el.ej2_instances[0];
grid.addRecord(); // perform the add action in Grid
}
},
---
},
};
</script>
|
|
[App.vue]
actionBegin: function (args) {
if (args.requestType === "save" && args.action === "add") {
var grid = this.$refs.grid.$el.ej2_instances[0];
args.index = grid.currentViewData.length; // add the record at bottom of Grid
}
},
|
|
[App.vue]
actionComplete: function (args) {
var grid = this.$refs.grid.$el.ej2_instances[0];
if (args.requestType === "save" && args.action === "add") {
grid.addRecord(); // execute the addRecord method after saving action done
}
if (args.requestType === "add") {
setTimeout(() => {
args.form.querySelector("#" + grid.element.id + "OrderID").focus(); // focus the input of OrderID column
}, 100);
}
},
|
Hi Rajapandiyan,
Thanks for you reply. I am able to add new empty record but unable to set focus to the input.
I am getting below error
I have editTemplate in row's first column
Package.json
Regards,
Sandeep G
|
[App.vue]
actionComplete: function (args) {
if (args.requestType === "save" && args.action === "add") {
var grid = this.$refs.grid.$el.ej2_instances[0];
// execute the addRecord method after some time interval to maintain the focus
setTimeout(() => {
grid.addRecord();
}, 200);
}
},
|