Version

Apply Default Summary Formats

You can format a summary value by setting the StringFormat property of a SummaryDefinition object in a field layout’s SummaryDefinitions collection; however, xamDataPresenter™ offers an alternative way to format summary values using very little code. You can set the SummaryStringFormats property of a Field object to apply default formatting for summaries in that field.

You can set the SummaryStringFormats property to a comma-delimited list of formats for the different calculators. Each token in the comma-delimited string must start with the name of a summary calculator, followed by a colon, and then a composite format string. For example, if you want to format the value of the sum and average calculator, you can set the Field object’s SummaryStringFormats property to "sum:Total Revenue = {0:c}, average: Mean Revenue = {0:c}". In addition to the ('0') placeholder, you can also use the following placeholders in your composite format string:

  • {0} - Represents the actual value of the summary.

  • {1} - Represents the name of the summary calculator that is being used to calculate this summary.

  • {2} - Represents the SummaryDefinition object’s Key property.

  • {3} - Represents the name of the field that is being used to calculate this summary.

The following example code demonstrates how to apply default summary formats. The example code assumes you have a field named "revenue" in your field layout.

In XAML:

...
<igDP:Field
    Name="revenue"
    Label="Revenue"
    SummaryStringFormats="{}sum:Revenue = {0:c}, average:Mean Revenue = {0:c}" />
...

In Visual Basic:

...
Me.xamDataPresenter1.FieldLayouts(0).Fields("revenue").SummaryStringFormats = "sum:Revenue = {0:c}, average: Mean Revenue = {0:c}"
...

In C#:

...
this.xamDataPresenter1.FieldLayouts[0].Fields["revenue"].SummaryStringFormats = "sum:Revenue = {0:c}, average: Mean Revenue = {0:c}";
...