This sample demonstrates formatting the appearance of pivot table cells with user-defined styles based on applied conditions. The Conditional Formatting dialog is invoked to add conditions and styles for the conditions. The formatting can be added, removed, and reset dynamically as well.
Conditional formatting works only for cells with values,
allowing the users to change its appearance such as background color, font color, font family, and font size based on specific conditions.
Conditional formatting can be applied either through UI or code behind. To enable this option in UI, set
allowConditionalFormatting
to true and invoke
showConditionalFormattingDialog
method to view the UI.
To achieve this in code-behind, set
allowConditionalFormatting
to true and use the
conditionalFormatSettings
object in the pivot table along with the following properties.
Both options are enabled in this sample.
measure :
|
Specifies the value field name for which style will be applied. |
condition :
|
Specifies the operator type like equals, greater than, less than, etc. |
value1 :
|
Specifies the start value. |
value2 :
|
Specifies the end value. |
style :
|
Specifies the style for the cell. |
applyGrandTotals :
|
Enabled by default. Allows conditional formatting to be applied to row and column grand totals. |
Also, user can clear the entire style applied for the value cell using reset all option.
Injecting Module:
The pivot table features are segregated into individual modules.
To enable conditional formatting, inject
ConditionalFormatting
module using the
services
tag.
More information on the conditional formatting can be found in this documentation section.