I have a bool column in a grid with groupings. In order to display an indicator on the group row that shows if any of the child rows in the group are checked I used a CustomSummaryCalculator class that looks like this.
internal class DoFxCustomSummary : ICustomSummaryCalculator
{
private bool total;
public void BeginCustomSummary(SummarySettings summarySettings, RowsCollection rows)
total = false;
}
public void AggregateCustomSummary(SummarySettings summarySettings, UltraGridRow row)
if(total)
total = true;
else
if(((FXOMAllocationBean)row.ListObject).DoFx)
public object EndCustomSummary(SummarySettings summarySettings, RowsCollection rows)
return "X";
return "";
This code works fine except when the value show up in the grid group row it picks up the default format and looks like this Summary = X. O only what to see X. I need to set the DisplayFormat property of the SummarySetting to something that will have a place holder for a literal and for the life of me I cannot find how to do it. I have seen a million examples of numeric formats or date formats but nothing that contains a literal. At this point I am going a bit nuts. So far I spent 2 days for something so trivial. PLEASE HELP!!!
OK, there are no stupid questions, but this one comes close.
I guess in this case the key peace of info I was not getting was the fact the DisplayFormat works like string,Format function and there is no character that represents a literal. The answer to my question is 0 as the first parameter to a Format function. Or to be more exact SummarySetting.DispalyFormat = "{0}". It is always 0, whether the value is alpha, numeric or date.
Set the SummarySettings DisplayFormat to "{0}"
Hi Mike,
Thank you for answering my question. And if I may a followup...
EndCustomSummary method of ICustomSummaryCalculator interface returns and object. What are possible 'objects' that a grid can render in a summary. For example can I replace an X in my example with an image or will it not get rendered?
The object you pass back will become the Value of the SummaryValue. The grid will call the ToString method on this object and plug that string into the DisplayFormat for the summary.
So if you supply an image, you will see the ToString method of the image, which is something like {System.Drawing.Image}. You won't see the actual image. In theory, if you want to make this work, you could do is using a CreationFilter or a DrawFilter to extract the actual Image from the value and display it in the summary value. But it would take some coding.