Skip to content

Commit

Permalink
Fix cellData null error (briangann#67)
Browse files Browse the repository at this point in the history
* Fix cellData null error

* Fix prettier error
  • Loading branch information
peterhpchen authored and briangann committed Sep 7, 2019
1 parent a7c1ae1 commit 6b9a7af
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ export class DatatableRenderer {
}

getCellColors(colorState: any, columnNumber: any, cellData: any) {
if (cellData === null || cellData === undefined) {
return null;
}
const items = cellData.split(/([^0-9.,]+)/);
// only color cell if the content is a number?
let bgColor = null;
Expand Down Expand Up @@ -451,6 +454,9 @@ export class DatatableRenderer {
// only columns of type undefined are checked
if (_this.table.columns[columnNumber].type === undefined) {
rowColorData = _this.getCellColors(_this.colorState, columnNumber, rowData[columnNumber + rowNumberOffset]);
if (!rowColorData) {
continue;
}
if (rowColorData.bgColorIndex !== null) {
if (rowColorData.bgColorIndex > rowColorIndex) {
rowColorIndex = rowColorData.bgColorIndex;
Expand Down Expand Up @@ -484,6 +490,9 @@ export class DatatableRenderer {
// only columns of type undefined are checked
if (_this.table.columns[columnNumber].type === undefined) {
rowColorData = _this.getCellColors(_this.colorState, columnNumber, rowData[columnNumber + rowNumberOffset]);
if (!rowColorData) {
continue;
}
if (rowColorData.bgColorIndex !== null) {
if (rowColorData.bgColorIndex > rowColorIndex) {
rowColorIndex = rowColorData.bgColorIndex;
Expand Down Expand Up @@ -516,6 +525,9 @@ export class DatatableRenderer {
// 2) RowColumn is enabled, the above row color is process, but we also
// set the cell colors individually
const colorData = _this.getCellColors(_this.colorState, actualColumn, cellData);
if (!colorData) {
return;
}
if (_this.colorState.cell || _this.colorState.rowcolumn) {
if (colorData.color !== undefined) {
$(td).css('color', colorData.color);
Expand Down

0 comments on commit 6b9a7af

Please sign in to comment.