App.Component.html
<ejs-grid #batchgrid id='Batchgrid' [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [editSettings]='editSettings' [toolbar]='toolbar' (cellSave)="cellSave($event)" (load)="load($event)">
. . .
</ejs-grid> |
App.component.ts
export class AppComponent {
. . .
public ngOnInit(): void {
. . .
cellSave(args) {
console.log(args);
}
load(args){
this.grid.element.addEventListener('mousedown', (e: MouseEventArgs) => {
let rowcell = parentsUntil(e.target as HTMLElement, "e-rowcell");
if (rowcell) {
let index: number = parseInt(rowcell.getAttribute("Index"));
let colindex: number = parseInt(rowcell.getAttribute("aria-colindex"));
let field: string = this.grid.getColumns()[colindex].field;
this.grid.editModule.editCell(index, field);
};
});
this.grid.element.addEventListener('keydown', (e: KeyboardEventArgs) => {
let templatecell = parentsUntil(e.target as HTMLElement, "e-templatecell");
if (this.grid.isEdit && e.code === 'Enter' && templatecell) {
let index: number = parseInt(templatecell.getAttribute("Index"));
let colindex: number = parseInt(templatecell.getAttribute("aria-colindex"));
let field: string = this.grid.getColumns()[colindex].field;
index === this.grid.getRows().length - 1 ? this.grid.editModule.saveCell(): this.grid.editModule.editCell(index + 1, field);
}
});
}
} |
App.Component.html
<ejs-grid #batchgrid id='Batchgrid' [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [editSettings]='editSettings' [toolbar]='toolbar' (cellSave)="cellSave($event)" (load)="load($event)">
. . .
</ejs-grid> |
App.component.ts
export class AppComponent {
. . .
public ngOnInit(): void {
. . .
cellSave(args) {
console.log(args);
}
load(args){
this.grid.element.addEventListener('mousedown', (e: MouseEventArgs) => {
let rowcell = parentsUntil(e.target as HTMLElement, "e-rowcell");
if (rowcell) {
let index: number = parseInt(rowcell.getAttribute("Index"));
let colindex: number = parseInt(rowcell.getAttribute("aria-colindex"));
let field: string = this.grid.getColumns()[colindex].field;
this.grid.editModule.editCell(index, field);
};
});
this.grid.element.addEventListener('keydown', (e: KeyboardEventArgs) => {
let templatecell = parentsUntil(e.target as HTMLElement, "e-templatecell");
if (this.grid.isEdit && e.code === 'Enter' && templatecell) {
let index: number = parseInt(templatecell.getAttribute("Index"));
let colindex: number = parseInt(templatecell.getAttribute("aria-colindex"));
let field: string = this.grid.getColumns()[colindex].field;
index === this.grid.getRows().length - 1 ? this.grid.editModule.saveCell(): this.grid.editModule.editCell(index + 1, field);
}
});
}
} |