Skip to content

Instantly share code, notes, and snippets.

@loonix
Created April 9, 2019 15:20
Show Gist options
  • Save loonix/d7266ada5ff9938757b6c9227ba14d30 to your computer and use it in GitHub Desktop.
Save loonix/d7266ada5ff9938757b6c9227ba14d30 to your computer and use it in GitHub Desktop.
SlickGrid on cell change highlight and flash cell and apply class
/*
<angular-slickgrid gridId="importGrid" [columnDefinitions]="columnDefinitions" [gridOptions]="gridOptions"
[dataset]="dataset" (onAngularGridCreated)="angularGridReady($event)"
(sgOnCellChange)="onCellChanged($event.detail.eventData, $event.detail.args)" <----- required
>
</angular-slickgrid>
*/
onCellChanged(e, args): void {
this.highlightCell(args.row, args.cell, Object.keys(args.item)[args.cell]);
}
highlightCell(row, cell, colId): void {
(this.angularGrid.gridService as any)._grid.flashCell(row, cell, 2000); // Flashes the cell
const cssCellStyle = {};
const classToInject = 'invalid';
(cssCellStyle[row] = {})[colId] = classToInject;
(this.angularGrid.gridService as any)._grid.setCellCssStyles(`${classToInject}.${colId}.${row}`, cssCellStyle); // Applies the .invalid class to the cell
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment