Ultragrid GroupRow Summary: setting the caption (Displayformat, ..?)
New DiscussionHi,
my Ultragrid (v23.2) is databound to a DataTable. I use the code below code to add two summaries, one is a “ordinary” row count and the other is a custom made distinct count for a specific column CustomerID. This works fine as long as the summaries are at the end of the grid. But as soon as I group by a column, the caption of the group row header is wrong. I experimented wird summary.Displayformat, band.GroupByRowDescriptionMask and others, but to no avail.
What I’d need is something like this, when e.g. grouping column is “city”:
City Hamburg: 45 rows, 8 DistinctCustomers
What I get is:
City: Hamburg: CustomerID CustomerIDs: 45, distinct CustomerIDs: 8
As you see, the name of the aggregated column ist redundant. How can I remove it form the group row caption?
See attachment for graphics :).
My Code:
var bndAP = ugr.DisplayLayout.Bands[0];
bndAP.Override.GroupByRowDescriptionMask = "[caption]: [value]";
if (!bndAP.Summaries.Exists("CountRows"))
{
var summary = bndAP.Summaries.Add(
"CountRows",
SummaryType.Count,
bndAP.Columns["CustomerID"]);
summary.DisplayFormat = "CustomerIDs: {0}";
summary.Appearance.FontData.Bold = DefaultableBoolean.True;
summary.SummaryPosition = SummaryPosition.Left;
summary.SummaryDisplayArea = SummaryDisplayAreas.InGroupByRows | SummaryDisplayAreas.BottomFixed;
}
if (!bndAP.Summaries.Exists("DCountCustomerIDs"))
{
var summary = bndAP.Summaries.Add(
"DCountCustomerIDs",
SummaryType.Custom,
new DistinctCountSummaryCalculator(),
bndAP.Columns["CustomerID"],
SummaryPosition.Left,
null
);
summary.DisplayFormat = "distinct CustomerIDs: {0}";
summary.Appearance.FontData.Bold = DefaultableBoolean.True;
summary.SummaryPosition = SummaryPosition.Left;
summary.SummaryDisplayArea = SummaryDisplayAreas.InGroupByRows | SummaryDisplayAreas.BottomFixed;
}
