Menu
Download Free Trial
Table of contents

addCondition

addCondition(condition:Conditional Format Object)

[starting from version: 1.5]

Adds a conditional formatting rule for cell values to format them with specific styles if the condition for the cell value is met.

Use refresh() API call after to redraw the component and see changes.

Parameters

Conditional Format Object – the object that describes the conditional formatting rule.

Examples

If cell value is more than 100, then apply trueStyle to this cell:

var condition = {
  id: 1,
  formula: 'if(#value > 100, "trueStyle")',
  trueStyle: {fontSize : 10, backgroundColor: "#33BB33"},
};
flexmonster.addCondition(condition);
flexmonster.refresh();

This rule will be applied only to Sales measure totals and subtotals cells. If Sales is between 100000 and 200000, then apply trueStyle to the cell, else apply false style.

var condition = {
  id: 2,
  measure: "Sales",
  isTotal: true,
  formula: 'if(AND(#value > 100000, #value < 200000), "trueStyle", "falseStyle")',
  trueStyle: {fontSize : 11, backgroundColor: "#00FF00"},
  falseStyle: {fontSize : 11, color: "#000000"}
};
flexmonster.addCondition(condition);
flexmonster.refresh();

See also

getCondition
getAllConditions
removeCondition
removeAllConditions
refresh