app.component.html
<ejs-grid #grid [dataSource]='data'(actionComplete)='actionComplete($event)' (cellSave)="onsave($event)" [editSettings]='editSettings' [toolbar]='toolbar' [height]='150'>
<e-columns>
<e-column field='CaloriesIntake' headerText='Calories Intake' textAlign='Right' [validationRules]='customerIDRules' [valueAccessor]='totalCalories' width=150></e-column> //give fieldName for custom column also
</e-columns>
</ejs-grid>
app.component.ts
export class AppComponent {
------
actionComplete(args) {
if(args.requestType == 'beginEdit'){
for (var i = 0; i < args.form.elements.length; i++) {
if (args.form.elements[i].name == 'Protein' || args.form.elements[i].name == 'Fat' || args.form.elements[i].name == 'Carbohydrate') {
//bind the oninput event only for protein, fat and carbohydrate columns
args.form.elements[i].oninput = (args) => {
var x = this.grid.element.getElementsByClassName('e-gridform')[0].getElementsByClassName('e-input');
var value1, value2, value3, target;
for (var i = 0; i < x.length; i++) {
// get the values of protein, fat and carbohydrate columns
switch (x[i].name) {
case 'Protein': value1 = +x[i].value;
case 'Fat': value2 = +x[i].value;
case 'Carbohydrate': value3 = +x[i].value;
case 'CaloriesIntake': target = x[i]; // get the target element
}
}
target.value = value1 * 4 + value2 * 4 + value3 * 9; // change the target element value
}
}
}
}
}
}
|
hello,
looks like this is valid only for Normal editing could you please check of batch editing as well
Karthik,
After reviewing your query, we could see that you are using Batch editing in your application and like to get an event when editing the specific cell. We would like to inform you that when you edit the cell in the batch editing the cellEdit event gets triggered. So, you can perform your own action and achieve your requirement with the cellEdit event of Grid. Please refer the below API documentation for more information.
API: https://helpej2.syncfusion.com/react/documentation/api/grid/#celledit