﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - Lounge - Using a CustomAggregate result in a group header's GroupRowInfoText</title><link>http://www.intersoftsolutions.com/Community/Lounge/Using-a-CustomAggregate-result-in-a-group-headers-GroupRowInfoText/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Using a CustomAggregate result in a group header's GroupRowInfoText</title><link>http://www.intersoftsolutions.com/Community/Lounge/Using-a-CustomAggregate-result-in-a-group-headers-GroupRowInfoText/</link><pubDate>Tue, 26 Jul 2011 11:43:49 GMT</pubDate><dc:creator>RobertPehrson</dc:creator><description>&lt;p&gt;Here is an outline of my workaround to show how a group value can be aggregated and included in formatted text in the group header.  &lt;/p&gt;
&lt;p&gt;The process is initiated by the InitializeRow event: &lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; grid.InitializeRow &amp;#43;= OnInitializeRow;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;The event handler picks out the rows that are group headers.  In my application, there are nested groups, and the whole group hierarchy has to be processed to aggregate values; so my InitializeRow handler picks out the group headers at the top of the hierarchy:&lt;/p&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;pre&gt;private void OnInitializeRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e)
{
    WebGridRow row = e.Row;

    if (row.Type == RowType.GroupHeader)
    {
        if (row.Parent == null)
        {   
            // this group header row is at the top of the group hierarchy
            PopulateGroupHeader(row);
        }
    }

    e.ReturnValue = true;
}
&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;The processing is done in a method that is called recursively for each level of the group hierarchy.&lt;/p&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;span style="font-family: consolas; font-size: 13px"&gt;&lt;pre&gt;private void PopulateGroupHeader(WebGridRow row)
{
    WebGridGroup group = row.GetGroup();

    // Detect which group is being processed...
    string col = group.Column.DataMember; 

    if (col == "outerGroupColumn")
    {
        // For nested groups, process the child groups...
        foreach (WebGridRow childRow in row.Children)
        {
            PopulateGroupHeader(childRow);
        }
    }
    else if (col == "innerGroupColumn")
    {
        // Process each row in the inner group...
        foreach (WebGridRow leafRow in row.Children)
        {
            if (leafRow.DataRow != null)
            {
                DataRow r = ((DataRowView)leafRow.DataRow).Row;

                // Access the columns in this row to form aggregated data...
                object datavalue = r["ColumnName"];
            }
        }

        //Use the aggregated data in a formatted string and place in the group header...
        row.Cells[0].GroupRowInfoText = "formatted text";
    }

&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;</description></item><item><title>Using a CustomAggregate result in a group header's GroupRowInfoText</title><link>http://www.intersoftsolutions.com/Community/Lounge/Using-a-CustomAggregate-result-in-a-group-headers-GroupRowInfoText/</link><pubDate>Mon, 25 Jul 2011 22:50:03 GMT</pubDate><dc:creator>MarTin</dc:creator><description>&lt;p&gt;Hello Robert,&lt;/p&gt;
&lt;p&gt;Would you mind to provide us with the sample that you have successfully worked on?&lt;/p&gt;
&lt;p&gt;Your sample would be very useful to be converted into a knowledge base, so that other user will get the benefit from your workaround sample.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;-Martin-&lt;/p&gt;</description></item><item><title>Using a CustomAggregate result in a group header's GroupRowInfoText</title><link>http://www.intersoftsolutions.com/Community/Lounge/Using-a-CustomAggregate-result-in-a-group-headers-GroupRowInfoText/</link><pubDate>Fri, 22 Jul 2011 10:32:11 GMT</pubDate><dc:creator>RobertPehrson</dc:creator><description>&lt;p&gt;Hi Martin&lt;/p&gt;
&lt;p&gt;Thanks for your confirmation that custom aggregate is not available in group headers. &lt;/p&gt;
&lt;p&gt;I do have a workaround.  Picking up each group header in an InitializeRow event handler, traversing its child rows to accumulate the aggregate result, and constructing the text using the result, I can then place the formatted text in the row's Cells[0].GroupInfoText.  &lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Robert&lt;/p&gt;</description></item><item><title>Using a CustomAggregate result in a group header's GroupRowInfoText</title><link>http://www.intersoftsolutions.com/Community/Lounge/Using-a-CustomAggregate-result-in-a-group-headers-GroupRowInfoText/</link><pubDate>Fri, 22 Jul 2011 03:35:43 GMT</pubDate><dc:creator>MarTin</dc:creator><description>&lt;p&gt;Hello Robert,&lt;/p&gt;
&lt;p&gt;I understand your point here, but it seems that using custom aggregate is not available for GroupRowInfoText in the group header.&lt;/p&gt;
&lt;p&gt;The sample shows the implementation custom aggregate on a column footer. You only need to set FooterText, i.e "Count = " and set AggregateFunction to custom.&lt;/p&gt;
&lt;p&gt;However, this is not applicable in Group header since it can be only used for built-in aggregate function only. Therefore, if you set GroupRowInfoFormat to [custom], it will display custom instead of the value being generated in custom aggregate.&lt;/p&gt;
&lt;p&gt;Hope this helps. Thank you.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;-Martin-&lt;/p&gt;</description></item><item><title>Using a CustomAggregate result in a group header's GroupRowInfoText</title><link>http://www.intersoftsolutions.com/Community/Lounge/Using-a-CustomAggregate-result-in-a-group-headers-GroupRowInfoText/</link><pubDate>Thu, 21 Jul 2011 12:47:04 GMT</pubDate><dc:creator>RobertPehrson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I am grouping grid rows and wish to use a CustomAggregate event handler to calculate a result from the grouped rows, and display that result in the group header. &lt;/p&gt;
&lt;p&gt;My problem is that I cannot find any syntax for the GroupRowInfoText to include the custom aggregate in the group header.  We have [caption], [value], [count],  and the built-in aggregate functions [sum()] [avg()], [min()] and [max()].  I guess I need something like [custom].&lt;/p&gt;
&lt;p&gt;The documentation and the example show a custom aggregate being added to a footer, but without a substitution tag - i.e. "Count =", and the aggregate value gets placed at the end.  Placing the custom aggregate at the end wouldn't be as flexible as a substitution tag, but it doesn't happen in group headers.  &lt;/p&gt;
&lt;p&gt;Can you explain how to get a custom aggregate into a group header?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Robert&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description></item></channel></rss>