


|
public customFn: (args: { [key: number]: number }) => boolean = (args: { [key: number]: number }) => {
// get the current cell element
this.currentCell = parentsUntil((<any>args).element.parentElement, 'e-rowcell');
// get the value of other cell
this.nextMaxCellValue = parseInt(this.currentCell.nextElementSibling.nextElementSibling.innerHTML, 10);
return args['value'] > 0 && this.nextMaxCellValue > args['value'];
}
|
|
[app.component.html]
<ejs-grid #grid [dataSource]='data' (dataBound)='dataBound($event)' (cellSave)='cellSave($event)' [editSettings]='editSettings' [toolbar]='toolbar' height='273px'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' isPrimaryKey='true' [validationRules]='orderIDRules' width=100></e-column>
<e-column field='minValue' headerText='Min Quentity' [validationRules]='minRules' width=120></e-column>
<e-column field='maxValue' headerText='Max Quentity' [validationRules]='maxRules' textAlign='Right' editType='numericedit' width=120></e-column>
<e-column field='stock' headerText='stock' editType='dropdownedit' width=150></e-column>
</e-columns>
</ejs-grid>
|
|
public cellSave(args: any): void {
if(args.columnName === 'minValue') {
// get current row index
this.editRowIndex = parseInt(args.cell.parentElement.getAttribute('aria-rowindex'), 10);
this.isApplyEdit = true;
}
}
|
|
public dataBound(): void {
this.grid.on('toolbar-refresh', this.toolbarRefreshFun, this);
}
public toolbarRefreshFun(): void {
if(this.isApplyEdit) {
// edit next cell
this.isApplyEdit = false;
this.grid.editModule.editCell(this.editRowIndex, 'maxValue'); // edit cell programmatically
this.grid.editModule.saveCell(); // save cell programmatically
}
}
|