Intersoft WebGrid Documentation
AggregateFunction Property
See Also  Example Send Feedback
ISNet.WebUI.WebGrid Namespace > WebGridColumn Class : AggregateFunction Property






Gets or sets the aggregate function which result will be shown in total rows or group total rows for a column.

Syntax

Visual Basic (Declaration) 
<ISNet.Serialization.XmlSerializableAttribute()>
<NotifyParentPropertyAttribute(True)>
<DefaultValueAttribute()>
<ISNet.Serialization.BinarySerializableAttribute()>
<DescriptionAttribute("Gets or sets the aggregate function which result will be shown in total rows or group total rows for a column.")>
Public Property AggregateFunction As AggregateFunctions
Visual Basic (Usage)Copy Code
Dim instance As WebGridColumn
Dim value As AggregateFunctions
 
instance.AggregateFunction = value
 
value = instance.AggregateFunction
C# 
[ISNet.Serialization.XmlSerializableAttribute()]
[NotifyParentPropertyAttribute(true)]
[DefaultValueAttribute()]
[ISNet.Serialization.BinarySerializableAttribute()]
[DescriptionAttribute("Gets or sets the aggregate function which result will be shown in total rows or group total rows for a column.")]
public AggregateFunctions AggregateFunction {get; set;}
Delphi 
public read-write property AggregateFunction: AggregateFunctions; 
JScript 
ISNet.Serialization.XmlSerializableAttribute()
NotifyParentPropertyAttribute()
DefaultValueAttribute()
ISNet.Serialization.BinarySerializableAttribute()
DescriptionAttribute("Gets or sets the aggregate function which result will be shown in total rows or group total rows for a column.")
public function get,set AggregateFunction : AggregateFunctions
Managed Extensions for C++ 
[ISNet.Serialization.XmlSerializableAttribute()]
[NotifyParentPropertyAttribute(true)]
[DefaultValueAttribute()]
[ISNet.Serialization.BinarySerializableAttribute()]
[DescriptionAttribute("Gets or sets the aggregate function which result will be shown in total rows or group total rows for a column.")]
public: __property AggregateFunctions get_AggregateFunction();
public: __property void set_AggregateFunction( 
   AggregateFunctions value
);
C++/CLI 
[ISNet.Serialization.XmlSerializableAttribute()]
[NotifyParentPropertyAttribute(true)]
[DefaultValueAttribute()]
[ISNet.Serialization.BinarySerializableAttribute()]
[DescriptionAttribute("Gets or sets the aggregate function which result will be shown in total rows or group total rows for a column.")]
public:
property AggregateFunctions AggregateFunction {
   AggregateFunctions get();
   void set (    AggregateFunctions value);
}

Example

 

The following example shows you to configure aggregate function using code behind.
C#Copy Code
private void WebGrid1_CustomAggregate(object sender,
ISNet.WebUI.WebGrid.CustomAggregateArgs e)
{
    if (e.Column.DataMember == "Status") 
    {
        WebGridRowCollection rows = e.Rows;
        int count = 0;
        for (int i=0; i < rows.Count; i++) 
        {
            WebGridCell cell = rows[i].Cells[e.Column.Position];
            if (cell.Value.ToString() == "Active")
            {
                count++;
            }
        }
        e.AggregateResult = count;
    }
}

Remarks

The aggregation functions such as Count, Sum, Average, Min and Max are generally applicable to most application's requirements. However, they do not allow you to perform your own calculation on the grouped rows or footer's totaling.

Note that you can specify the CustomAggregate to as much columns as you want, the CustomAggregate event will be invoked each time the WebGrid found the specified CustomAggregate Column in the rendering process.

WebGrid.NET 5.0 Enterprise allows you display the calculated values without has to enable the GroupTotal feature. With the new feature to display basic aggregate functions in group header, you can display the calculated values without has to enable the GroupTotal feature. This new feature is useful when you only need to display a small number of calculated values and therefore reducing unnecessary clutter in the Grid's user interface.

The format string for new aggregate functions that you can apply in group header:

  • sum(Column Name)
  • avg(Column Name)
  • min(Column Name)
  • max(Column Name)

For more information you can read Walkthrough: Using Custom Aggregate function in WebGrid.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

Reference

WebGridColumn Class
WebGridColumn Members

Tasks

How-to: Use avg aggregate in group header
How-to: Show group total for a specific table

Other Resources

Custom Aggregation
Displaying aggregate values in GroupHeader

©2012 Intersoft Solutions Corp. All Rights Reserved.