Yes! To have full control over how a data cell in a report looks based upon its value, simply add an
Event to your Report object (via
toolbar > Events...). Be sure the event
Type is set to "
rendercell" so that it is called each time a data cell is rendered.
Sample code for a "rendercell" event:
function (event) {
// get info about the data cell
var dataCell = event.target.getLastRenderedDataCell();
// only apply formatting to the Order_Total column
if (dataCell.columnName == 'Order_Total') {
if (dataCell.dataValue.getNumber() > 1000) {
dataCell.dataCellDiv.style.backgroundColor = 'rgba(0,250,0,0.5)';
} else if (dataCell.dataValue.getNumber() < 200 && dataCell.dataValue.isNotNull() ) {
dataCell.dataCellDiv.style.backgroundColor = 'rgba(250,0,0,0.5)';
}
}
}
The event.target property always points to the object that fired the event (a ReportWidget in this case). See the
Application API documentation for details on the classes and methods available.
The Events panel looks like this:
The resulting report column looks like this: