Hi Team,
I am working on an requirement where grid loads with empty row at bottom initially. When user enters data through the empty row and saves it, again a new empty row is added at the bottom.
When user tries to edit a row, on-click of row a new empty row(view mode) is getting added to the grid. As, I am using grid.addRecord() function in actionBegin(). How to restrict this on editing?
which event is appropriate to achieve my requirement actionBegin() or actionComplete() ?
Requirement: When user updates row on edit, empty row at bottom should be enabled back to edit mode without adding new row again.
(For you information, I have added
rowUpdatedData variable to pass custom-template data and update calculations along with storing other data of the row. So, we need to assign row data to
rowUpdatedData on edit and access it while saving to update calculations accordingly.)
I have added working sample with my requirement. Please let me know how to achieve this.
Regards,
Sandeep G
Attachment: IssueWithInlineEdit_e82a2a12.zip
Hi
Rajapandiyan,
Thanks for your prompt reply. Our requirement is to achieve this using normal edit with out using toolbar or batch edit. How can we achieve it with my existing setup?
Above given sample is not working.
Regards,
Sandeep G
Hi Rajapandiyan,
Thanks for your reply. I have mentioned our requirement below. Please help in achieving it with working sample attached by me.
[App.vue]
<template>
<div id="app">
<ejs-grid
----
:actionComplete="actionComplete"
:keyPressed="keyPressed"
>
----
</ejs-grid>
</div>
</template>
<script>
---
export default {
name: "App",
data() {
return {
---
isEnterKeyPressed: false
};
},
methods: {
keyPressed(args){
if(args.key === 'Enter'){
// make the flag variable as true if the pressed key is ‘Enter’
this.isEnterKeyPressed = true;
}
},
actionComplete(args) {
if (args.requestType === "save") {
var grid = this.$refs.SO_lineItem_Grid.$el.ej2_instances[0];
this.dataGrid = this.$refs.SO_lineItem_Grid.ej2Instances.dataSource;
if (args.action === "add" && this.isEnterKeyPressed) {
this.isEnterKeyPressed = false;
// Add a new record if we press Enter key on new row
setTimeout(() => {
grid.addRecord();
}, 200);
}else if(this.isEnterKeyPressed){
this.isEnterKeyPressed = false;
// Add a new record if we press Enter key on previously edited row
// grid.addRecord();
// Edit a last record if we press Enter key on previously edited row
if(args.rowIndex != grid.getCurrentViewRecords().length-1){
// select last row
grid.selectRow(grid.getCurrentViewRecords().length-1);
// edit a record
grid.startEdit();
}
}
}
},
};
</script>
|
Hi Rajpandiyan,
Thank for the update.
In the provided example, we can only edit added record by pressing "esc" on new row and empty row is not seen in grid. This will confuse user on how to add new row.
So my requirement here is to show empty row disabled(non-editable mode) when we are editing previously added row and toggle it back to editable mode with cursor on first row after editing is completed.
Please help me achieve this.
Regards,
Sandeep G