- 3 min to read
The Grid dashboard item supports the conditional formatting feature that provides the capability to apply formatting to grid cells whose values meet the specified condition. This feature allows you to highlight specific cells or entire rows using a predefined set of rules. To learn more about conditional formatting concepts common for all dashboard items, see the Conditional Formatting topic.
- Conditional Formatting Overview
- Create a Format Rule
- Edit a Format Rule
- Create a Format Rule in Code
Conditional Formatting Overview
The Grid dashboard item allows you to apply conditional formatting to data items providing data to the following column types.
You can use hidden measures to specify a condition used to apply formatting to visible values.
New appearance settings are applied to grid cells corresponding to the target dimension/measure values.
Create a Format Rule
To create a new format rule for the Grid's dimension/measure, do one of the following.
Click the Options button next to the required measure/dimension, select Add Format Rule and choose the condition.
Right-click the column header corresponding to the required measure/dimension and select Add Format Rule.
- Use the Edit Rules dialog.
Depending on the selected format condition, the dialog used to create a format rule for Grid contains different settings. For instance, the image below displays the Greater Than dialog corresponding to the Value format condition.
The Apply to row check box allows you to specify whether to apply the formatting to the entire grid row.
Edit a Format Rule
To edit format rules for the current Grid dashboard item, use the following options.
- Click the Edit Rules button in the Home ribbon tab or use corresponding item in the Grid context menu.
- Click the menu button for the required data item and select Edit Rules. As an alternative, right-click the column header corresponding to the required data item and select Edit Rules.
All of these actions invoke the Edit Rules dialog containing existing format rules. To learn more, see Conditional Formatting.
Create a Format Rule in Code
The Grid dashboard item allows you to apply conditional formatting to cells. The GridDashboardItem.FormatRules property provides access to a collection of the GridItemFormatRule objects that are used to define formatting settings.
To add a new format rule, create the GridItemFormatRule object and specify the following settings.
- Create a required condition (the FormatConditionBase descendant), specify its settings and assign the resulting object to the DashboardItemFormatRule.Condition property.
- Set a measure/dimension whose values are checked using the specified condition by specifying the CellsItemFormatRule.DataItem property. The CellsItemFormatRule.DataItemApplyTo property specifies the measure/dimension to whose values a formatting should be applied.
- Optionally, enable the CellsItemFormatRule.ApplyToRow flag to apply formatting to the entire grid row.