Creating an Aggregated DataGrid

Reference:

This topic provides sample code for creating an aggregated DataGrid. It also describes the API filter function.


Top of page

Example: Sample Code for Creating an Aggregated DataGrid
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute" creationComplete="initApp()">
  <mx:Script>
    <![CDATA[ 
      import mx.charts.HitData; 
      import mx.controls.Alert; 
      import mx.collections.ArrayCollection; 
      public var grid1:ibiObject = new ibiObject(); 
      public var fex:String = "http://localhost:8080/ibi_apps/WFServlet
         ?IBIF_ex=xmltest"; 
      public function initApp():void 
      { 
        grid1.init(fex,dataReady); 
      } 
      public function dataReady(grid:ibiObject,obj:*):void 
      {  
        grid1.populateGrid(false); 
        load_main1agg(); 
      }
      public function load_main1agg():void 
      { 
         var aggField:Array = new Array(); 
         var byField:Array = new Array(); 
         var calOpts:Array = new Array(); 
         aggField.push("DOLLARS"); 
         byField.push("ST"); 
         byField.push("REGION");	  
         calOpts.push("Sum","Average");
         grid1.aggregate(aggField,byField,calOpts, true, false);
         main1agg.dataProvider = grid1.prGridagg; 
      } 
    ]]> 
  </mx:Script>
  <mx:DataGrid x="10" y="38" width="435" id="main1agg" height="193"> 
    <mx:columns> 
      <mx:DataGridColumn id="col1" headerText="Region"
          dataField="REGION"/> 
      <mx:DataGridColumn id="col2" headerText="State" dataField="ST"/> 
      <mx:DataGridColumn id="col3" headerText="Total Sales"
          dataField="Sum.DOLLARS"/> 
      <mx:DataGridColumn id="col4" headerText="Average Sales"
          dataField="Average.DOLLARS"/> 
    </mx:columns> 
  </mx:DataGrid> 
</mx:Application>

Top of page

x
Reference: Filter Function
public function filter(filterColumnName:Array,filterOption:Array, filterString:Array,condition:Array,caseSen:Boolean):ArrayCollection

Description:
Generates an ArrayCollection containing the grid rows that meet a certain condition or conditions. The condition is specified in the filterOption parameter. The filterColumnName parameter specifies which column of the grid is used to search for values meeting the specified condition. The filterString parameter specifies which value is used as the condition for the filter. This function stores all rows that meet the filter criteria in an ArrayCollection named prGridfiltered, which is returned as the resulting value of the function. The prGridfiltered can be used as a dataProvider for a DataGrid, which will show the results of the call to the filter function. Arrays are filterColumnName, filterOption, and filterString. This allows the user to run multiple filters at the same time. The first item in each array corresponds to one filter. Each filter is combined using the condition parameter, which is also an array. The condition parameter could be "and" or "or." Two filters are combined using the Boolean "and" or "or" provided in the condition parameter. The parameter caseSen specifies whether the filter is case-sensitive or not.

Parameters:
filterColumnName of type Array: Specifies which grid column is used to search for values that meet the filter criteria.

filterOption of type Array: Specifies the filter condition used to search for values. Possible values of filterOption are EQ, NE, GT, GE, LT, LE, BT, and CT.

filterString of type Array. An Array of Arrays of Strings: Specifies the value that the filter function uses to filter the grid rows.

condition of type Array: Specifies how multiple filters are combined. The possible values for condition are "and" and "or."

caseSen of type Boolean: Specifies whether the filter is case-sensitive or not.


WebFOCUS