Aggregate functions..

Posts   
 
    
alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 05-Dec-2004 20:15:48   

Could someone please explain a little more about what aggregate functions are. From what I've read, I think that's what I need to implement the functionality I want, but the documentation doesn't describe a scenario like mine.

I have a typed list that contains, among others, a Quantity field. That typed list is displayed in an Infragistics grid. At the end of my web form, I need to know what the total quantity is for all of the records in the grid.

Should I iterate back through the typed list and count the quantity manually, or is that something an aggregate function would do? I don't really want to make another call to the database either.

Thanks so much for the help!

thomas
User
Posts: 24
Joined: 21-Oct-2004
# Posted on: 05-Dec-2004 22:54:56   

Use the item_databound of the infragistic grid to add the value of quantity field to a form/page level variable. After all records are bound you can drop the total into a label thats placed in the footer of the grid. I've never used Infragistics but its quite possible they may even have some predefined functionality to do totals built into the control as well.......

Thomas

alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 06-Dec-2004 06:09:05   

thomas wrote:

Use the item_databound of the infragistic grid to add the value of quantity field to a form/page level variable. After all records are bound you can drop the total into a label thats placed in the footer of the grid. I've never used Infragistics but its quite possible they may even have some predefined functionality to do totals built into the control as well.......

Thomas

Well, it the grid WILL have that functionality when they release their CalcEngine product. It was supposed to come out in November, but hasn't yet.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 06-Dec-2004 09:54:53   

Aggregate functions are applied to groups of data. So if you want the total price per OrderID, you select orderid from orderdetails and group by OrderId and apply the SUM aggregate function on the product price (for example). As per orderID there are several order detail rows, the group of 1 orderid will contain 1 or more product prices. These are then fed to the aggregate function by the database engine. See for more information the aggregate functions / group by documentation of the database you use.

Frans Bouma | Lead developer LLBLGen Pro
thomas
User
Posts: 24
Joined: 21-Oct-2004
# Posted on: 06-Dec-2004 15:50:52   

Yep I'm personally not a big fan of Infragistics... simple_smile Did you have any luck with either my suggestion or Otis' ?

Thomas

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 06-Dec-2004 21:19:11   

Actually, the Infragistics Win Grid does have that functionality since the 2003 version, I believe. Check out this code:


    Private Sub NewSummary(ByVal Column As Infragistics.Win.UltraWinGrid.UltraGridColumn)
        Dim Summary As Infragistics.Win.UltraWinGrid.SummarySettings
            If Column.AllowRowSummaries = UltraWinGrid.AllowRowSummaries.True Then
                Summary = grdStations.DisplayLayout.Bands(0).Summaries.Add(Column.Key, Infragistics.Win.UltraWinGrid.SummaryType.Sum, Column)
                Summary.DisplayFormat = "{0:#####}"
            End If
    End Sub

Let me know if you have any questions.

Jeff...