﻿<?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 - WebGrid Enterprise - about CustomAggregate function question?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/about-CustomAggregate-function-question/</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>about CustomAggregate function question?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/about-CustomAggregate-function-question/</link><pubDate>Mon, 08 Feb 2010 21:45:04 GMT</pubDate><dc:creator>rogerchen.tangshuo@gmail.com</dc:creator><description>&lt;p&gt;Thank you, I make a mistake, so GetCachedDataSource() return is null, now it can work, thanks again&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Best Regards&lt;/p&gt;</description></item><item><title>about CustomAggregate function question?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/about-CustomAggregate-function-question/</link><pubDate>Mon, 08 Feb 2010 21:01:51 GMT</pubDate><dc:creator>rogerchen.tangshuo@gmail.com</dc:creator><description>&lt;p&gt;I try to using the snippet code, but GetCachedDataSource() function always return null, (AllowAutoDataCaching=True, AlwaysUseCachedDataOnFirstLoad=False). How can i do?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Best Regards&lt;/p&gt;</description></item><item><title>about CustomAggregate function question?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/about-CustomAggregate-function-question/</link><pubDate>Mon, 08 Feb 2010 04:50:40 GMT</pubDate><dc:creator>Glayaar</dc:creator><description>&lt;p&gt;You could modify the snippet so instead of iterating e.Rows you will iterate the WebGrid datasource or you will need to requery the data if the WebGrid do not cache the data.&lt;/p&gt;&lt;p&gt;Here is the updated snippet that will iterate the WebGrid datasource, in my scenario the DataSource is a DataTable:&lt;/p&gt;&lt;pre&gt;protected void wgTest_CustomAggregate(object sender, ISNet.WebUI.WebGrid.CustomAggregateArgs e)&lt;br /&gt;{&lt;br /&gt;    if (e.Column.DataMember == "Date")&lt;br /&gt;    {&lt;br /&gt;        DataTable dtSource = (DataTable)wgTest.GetCachedDataSource();&lt;br /&gt;        Double sumVal = 0;&lt;br /&gt;        Double sumValX = 0;&lt;br /&gt;        for (int i = 0; i &amp;lt; dtSource.Rows.Count; i&amp;#43;&amp;#43;)&lt;br /&gt;        {&lt;br /&gt;            sumVal &amp;#43;= (Double)dtSource.Rows[i]["Value"];&lt;br /&gt;&lt;br /&gt;            sumValX &amp;#43;= (Double)dtSource.Rows[i]["ValueX"];&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        e.AggregateResult = sumValX &amp;#43; " / " &amp;#43; sumVal &amp;#43; " : " &amp;#43; ((Double)(sumValX / sumVal)).ToString("#.#0");&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>about CustomAggregate function question?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/about-CustomAggregate-function-question/</link><pubDate>Mon, 08 Feb 2010 02:28:54 GMT</pubDate><dc:creator>rogerchen.tangshuo@gmail.com</dc:creator><description>&lt;p&gt;Thanks a lot, If webgrid in SelfReferencing mode and ColumnFooterAggregateMode="CalculateAllData", how to use CustomAggregate API calculate all data? this example only  calculate the level 1 rows. not all data.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Best Regards&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description></item><item><title>about CustomAggregate function question?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/about-CustomAggregate-function-question/</link><pubDate>Sun, 07 Feb 2010 21:53:21 GMT</pubDate><dc:creator>Glayaar</dc:creator><description>&lt;p&gt;CustomAggegrate function has already support this scenario. For example if you wish to calculate the sum[ValueX] / sum[Value] on the column Date. Here is the snippet:&lt;/p&gt;&lt;pre&gt;protected void wgTest_CustomAggregate(object sender, ISNet.WebUI.WebGrid.CustomAggregateArgs e)&lt;br /&gt;{&lt;br /&gt;    if (e.Column.DataMember == "Date")&lt;br /&gt;    {&lt;br /&gt;        WebGridRowCollection rows = e.Rows;&lt;br /&gt;        Double sumVal = 0;&lt;br /&gt;        Double sumValX = 0;&lt;br /&gt;        for (int i = 0; i &amp;lt; rows.Count; i&amp;#43;&amp;#43;)&lt;br /&gt;        {&lt;br /&gt;            WebGridCell cellVal = rows[i].Cells.GetNamedItem("Value");&lt;br /&gt;            sumVal &amp;#43;= (Double)cellVal.Value;&lt;br /&gt;&lt;br /&gt;            WebGridCell cellValX = rows[i].Cells.GetNamedItem("ValueX");&lt;br /&gt;            sumValX &amp;#43;= (Double)cellValX.Value;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        e.AggregateResult = ((Double)(sumValX / sumVal)).ToString("#.#0");&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;In this example both the Value and ValueX column has a Double datatype.&lt;/p&gt;
&lt;p&gt;You could read the CustomAggegrate walkthrough in or WebGrid documentation under the article "Walkthrough: Using Custom Aggregate function in WebGrid"&lt;br /&gt;&lt;/p&gt;</description></item><item><title>about CustomAggregate function question?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/about-CustomAggregate-function-question/</link><pubDate>Fri, 05 Feb 2010 09:29:27 GMT</pubDate><dc:creator>rogerchen.tangshuo@gmail.com</dc:creator><description>&lt;p&gt;Is there a way set some column ( for example columnC ) footer value  is sum(columnA)/sum(columnB) by useing  CustomAggregate function?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description></item></channel></rss>