Skip to content

Commit

Permalink
fix: onBeforeAppendCell should only be used when it's a string (#802)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
ghiscoding authored Jun 30, 2023
1 parent b31a797 commit b367209
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions slick.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -3459,9 +3459,13 @@ if (typeof Slick === "undefined") {
}

// get addl css class names from object type formatter return and from string type return of onBeforeAppendCell
// 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)
const evt = trigger(self.onBeforeAppendCell, { row: row, cell: cell, value: value, dataContext: item });
var addlCssClasses = evt.getReturnValue() || '';
addlCssClasses += (formatterResult && formatterResult.addClasses ? (addlCssClasses ? ' ' : '') + formatterResult.addClasses : '');
var appendCellResult = evt.getReturnValue();
var addlCssClasses = typeof appendCellResult === 'string' ? appendCellResult : '';
if (formatterResult && formatterResult.addClasses) {
addlCssClasses += (addlCssClasses ? ' ' : '') + formatterResult.addClasses;
}
var toolTip = formatterResult && formatterResult.toolTip ? "title='" + formatterResult.toolTip + "'" : '';

var customAttrStr = '';
Expand Down

0 comments on commit b367209

Please sign in to comment.