BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
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
}
}
}
}
}
}
|