Monday, September 22, 2008
Data Field Aggregates

A common requirement in many applications is to display various aggregate values when data is presented in a grid view.

The latest release of Data Aquarium Framework introduces a new feature that does exactly that. Aggregate feature is shown in the following screen shot. See a live demo of this feature.

image

Columns Required Date, Shipped Date, and Freight are displaying values in the aggregate row at the bottom of the grid view just above the pager. Here is how these data fields are defined in grid1 view of data controller ~/Controllers/Orders.aspx in a sample application.

<view id="grid1" type="Grid" commandId="command1" label="Orders">
  <headerText>This is a list of orders. </headerText>
  <dataFields>
    <dataField fieldName="OrderID"/>
    <dataField fieldName="CustomerID" aliasFieldName="CustomerCompanyName" />
    <dataField fieldName="EmployeeID" aliasFieldName="EmployeeLastName" />
    <dataField fieldName="OrderDate" columns="10"/>
    <dataField fieldName="RequiredDate" columns="10"  aggregate="Max"/>
    <dataField fieldName="ShippedDate" columns="10"  aggregate="Max"/>
    <dataField fieldName="ShipVia" aliasFieldName="ShipViaCompanyName" />
    <dataField fieldName="Freight" dataFormatString="c" columns="15"
      aggregate="Sum"/>
    <dataField fieldName="ShipName" columns="40" />
  </dataFields>
</view>

Attribute aggregate specified an aggregate function that instructs the data controller to calculate aggregates when a total number of records in a data set is being determined.

An SQL statement with corresponding aggregate functions is executed, which provides maximum speed and efficiency. Many commercially available grids will calculate aggregates by scanning the entire record set. Data Aquarium Framework simply relies on speed and power of your database server.

Aggregates automatically take into account any filters that may have been imposed on a data set by users and master-detail links. In this illustration you can see orders filtered by Ship Via and Ship Name. Aggregates were recalculated accordingly.

image