Skip to content

Commit 9f2ce78

Browse files
authored
docs(pivotgrid): Document possible null value in the template
1 parent 73d8ea8 commit 9f2ce78

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

components/pivotgrid/templates.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ Define a column header template with a `<ColumnHeaderTemplate>` component. The `
2727

2828
## Data Cell Template
2929

30-
Define a data cell template with a `<DataCellTemplate>` component. The `context` is of type `PivotGridDataCellTemplateContext`. The `context` provides `Value` and `FormattedValue` properties, which represent the original measure values as `object`. You may need to cast them to the correct type before usage.
30+
Define a data cell template with a `<DataCellTemplate>` component. The `context` is of type `PivotGridDataCellTemplateContext`. The `context` exposes `Value` (`object`) and `FormattedValue` (`string`) properties.
31+
32+
* You may need to cast the `Value` property to the correct type before usage.
33+
* Depending on the Pivot Grid data and configuration, the `Value` property may be `null` and the `FormattedValue` may be an empty string.
3134

3235

3336
## Row Header Template
@@ -53,7 +56,10 @@ All template components expose an optional `Context` parameter. Set it in scenar
5356
@{
5457
var c = (PivotGridDataCellTemplateContext)dataCellContext;
5558
}
56-
@( ((decimal)c.Value).ToString("c2") )
59+
if (c.Value != null)
60+
{
61+
@( ((decimal)c.Value).ToString("c2") )
62+
}
5763
</DataCellTemplate>
5864
<RowHeaderTemplate>
5965
@{

0 commit comments

Comments
 (0)