Skip to content

Commit b367209

Browse files
authored
fix: onBeforeAppendCell should only be used when it's a string (#802)
- the `onBeforeAppendCell` event can be used to return CSS classes as shown in this [example2-formatters-event.html](http://6pac.github.io/SlickGrid/examples/example2-formatters-event.html), however when the user doesn't define or use this event then its result is always a `true` boolean and the way that the code was implemented, it was always showing "true" as a CSS class which we don't need at all - the original implementation was found in this old [commit](bef3203) and on top of that `onBeforeAppendCell` event is actually deprecated to use.
1 parent b31a797 commit b367209

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

slick.grid.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3459,9 +3459,13 @@ if (typeof Slick === "undefined") {
34593459
}
34603460

34613461
// get addl css class names from object type formatter return and from string type return of onBeforeAppendCell
3462+
// we will only use the event result as CSS classes when it is a string type (undefined event always return a true boolean which is not a valid css class)
34623463
const evt = trigger(self.onBeforeAppendCell, { row: row, cell: cell, value: value, dataContext: item });
3463-
var addlCssClasses = evt.getReturnValue() || '';
3464-
addlCssClasses += (formatterResult && formatterResult.addClasses ? (addlCssClasses ? ' ' : '') + formatterResult.addClasses : '');
3464+
var appendCellResult = evt.getReturnValue();
3465+
var addlCssClasses = typeof appendCellResult === 'string' ? appendCellResult : '';
3466+
if (formatterResult && formatterResult.addClasses) {
3467+
addlCssClasses += (addlCssClasses ? ' ' : '') + formatterResult.addClasses;
3468+
}
34653469
var toolTip = formatterResult && formatterResult.toolTip ? "title='" + formatterResult.toolTip + "'" : '';
34663470

34673471
var customAttrStr = '';

0 commit comments

Comments
 (0)