Using Filters

In this section:


Top of page

x
Setting Default Filters

In this section:



x
Setting the Default Value for the Filter

The ibiFilterDefault property can be used to set the default filters when the application is initialized or to apply WHERE conditions to the data.

To set the default value when using ibiFilterCond EQ, use the following syntax

ibiFilterDefault="value"

where:

value

Is the value being set as the default.

You can also specify any available filter condition using EQ/NE/GT/LT/LE/GE/BT/CT syntax when setting the value for ibiFilterDefault property. When ibiFilterDefault property is used in ibiComboBox or ibiList component, it sets the default value that displays in the ibiComboBox or the ibiList component and applies the filter based on the value when the application initializes. Because the field name is already identified by the ibiColumn property of the component, only the default value needs to be specified for ibiComboBox or ibiList component.

ibiFilterDefault="value"

where:

value

Is the value that you want to be set as the default value that displays.

In this case, you can specify the filter condition using ibiFilterCond property. The default is EQ.

To apply the WHERE condition, use the following syntax.

ibiFilterDefault="field_name EQ[NE,LT,GT,...] value"

Note: You can filter all the date in the application in two ways. You can filter by default based on the value set in one of the components when the application initially loads or you can apply filters individually based on the default value set in each component and use the filtered date to derive other components.



Example: Using the ibiFilterDefault Property

When ibiFilterDefault is used in filtering controls, such as ibiComboBox or ibiList, only the value is required.

<ibi:ibiComboBox x="10" y="155"
 id="combo1"
 ibiParent="mainGrid1"
 ibiColumn="REGION"
 ibiFilterAble="true"
 ibiFilterDefault="West"/>

When ibiFilterDefault is used in ibiDataGrid or any of ibi chart components, the column name and the value are required.

<ibi:ibiBarChart x="527" width="433" height="223" y="217"
 id="bar1"
 ibiParent="mainGrid"
 ibiGroupBy="STATE"
 ibiXField="Sum.PROFIT,Sum.COSTOFGOODSSOLD"
 ibiYField="STATE"
 ibiFilterDefault="PROFIT GE 500000"
 showDataTips="true" 
 ibiUseFiltered="true" />
<ibi:ibiDataGrid x="542" y="448" width="433"
 id="dataGrid1" 
 ibiParent="mainGrid"
 ibiUseFiltered="true"
 ibiGroupBy="REGION"
 ibiUseColumns="REGION,Sum.PROFIT,Sum.COSTOFGOODSSOLD"
 ibiFilterDefault="PRODUCTTYPE EQ Cameras" />

To apply the WHERE condition, use the following syntax.

ibiFilterDefault="field_name EQ[NE,LT,GT,...] value"

Note: You can filter all the data in the application in two ways. You can filter by default based on the value set in one of the components when the application initially loads or you can apply filters individually based on the default value set in each component and use the filtered data to derive other components.



x
ibiFilterDefault: Using the ibiFilterDefault Property With Charts

You can use the ibiFilterDefault property to limit data and apply a WHERE condition to IBI charts using the same syntax used for ibiDataGrid.

You can filter data and apply a WHERE condition by using the following syntax.

ibiFilterDefault="field_name EQ value"

where:

field_name

Is the name of the field you are filtering.

and:

value

Is the value you are filtering it on.

You can also specify any available filter condition using EQ/NE/GT/LT/LE/GE/BT/CT syntax when setting the value for ibiFilterDefault property. The ibiFilterDefault property is used differently in ibiComboBox or ibiList component. It sets the default value that displays in the ibiComboBox or the ibiList component and applies the filter based on the value when the application initializes. Because the field name is already identified by the ibiColumn property of the component, only the default value needs to be specified for ibiComboBox or ibiList component.

ibiFilterDefault="value"

where:

value

Is the value that you want to be set as the default value that displays.

In this case, you can specify the filter condition using ibiFilterCond property. The default is EQ.



Example: Using the ibiFilterDefault Property

When ibiFilterDefault is used in filtering controls such as ibiComboBox or ibiList, only the value is required.

<ibi:ibiComboBox x="10" y="155"
 id="combo1"
 ibiParent="mainGrid1"
 ibiColumn="REGION"
 ibiFilterAble="true"
 ibiFilterDefault="West"/>

When ibiFilterDefault is used in ibiDataGrid or any of ibi chart components, the column name and the value are required.

<ibi:ibiBarChart x="527" width="433" height="223" y="217"
 id="bar1"
 ibiParent="mainGrid"
 ibiGroupBy="STATE"
 ibiXField="Sum.PROFIT,Sum.COSTOFGOODSSOLD"
 ibiYField="STATE"
 ibiFilterDefault="PROFIT GE 500000"
 showDataTips="true" 
 ibiUseFiltered="true" />
<ibi:ibiDataGrid x="542" y="448" width="433"
 id="dataGrid1" 
 ibiParent="mainGrid" 
 ibiUseFiltered="true"
 ibiGroupBy="REGION" 
 ibiUseColumns="REGION,Sum.PROFIT,Sum.COSTOFGOODSSOLD"
 ibiFilterDefault="PRODUCTTYPE EQ Cameras" />

Top of page

x
Data Grid Drill Down Using @ibiFilterDefault Value

The ibiFilterDefault property can be used as a parameter to pass a value to implement the data grid drill down feature between two or more SWF files that are Adobe Flash Player compatible.

In the Script section of the parent SWF file that is Adobe Flash Player compatible, you can define the drill down parameter and construct the URL with the value to pass to the child SWF file that is Adobe Flash Player compatible. The drill down parameter accepts only a valid column name, filter condition, and value syntax as below.

var Parameter_Name:String = column_name +' filter_condition '+ value;
var url:String = 'child_swf_file_name.swf?ibiFilterDefault='+Parameter_Name;

In the drill down child SWF file that is Adobe Flash Player compatible, set the following value for ibiFilterDefault property to apply the filter to the data based on the value passed.

ibiFilterDefault="@ibiFilterDefault"


Example: Parent Drill Down Application Using @ibiFilterDefault

In the following example, clicking on a row in the parent data grid in the parent SWF file that is Adobe Flash Player compatible passes both the column name and the row value clicked as the ibiFilterDefault parameter value to the child SWF file that is Adobe Flash Player compatible.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    xmlns:ibi="http://www.informationbuilders.com" backgroundColor="#FFFFFF">
  <ibi:ibiCanvas id="pc" width="962" height="666" x="10" y="10">
    <mx:Label x="10" y="10" text="Click in the data grid to drill down..." 
        fontSize="12" fontWeight="bold" height="24" width="263"/>
    <ibi:ibiDataGrid width="692" height="455" x="10" y="42"
      itemClick="open_filtered_swf(event)"
      seturl="http://localhost:8080/ibi_apps/WFServlet?IBIF_ex=centurysales&amp;
              IBIAPP_app=ibiflexdemo"
      ibiUseColumns="PLANTREGION,STATE,CITY,STORENAME"
      id="dg1" />
  </ibi:ibiCanvas>
  <mx:Script>
     <![CDATA[
      import mx.events.ListEvent;
      private function open_filtered_swf(e:ListEvent):void
      {
        var o:Object = e.currentTarget;
        var column:String = o.columns[e.columnIndex].dataField;
        var val:String = o.selectedItem[column];
        // resolves @ibiFilterDefault to a column name, condition, and a value
        var DrillDownValue:String = column+' EQ '+val;
        // resolves the parameter name DrillDownValue to the data clicked on
        // and constructs drill down URL to pass to the child SWF file
        // with ibiFilterDefault set to the clicked value such as: 
        //.../filterDataGridViaParam.swf?ibiFilterDefault=CITY%20EQ%20New%20York%20City
        var url:String = 'DrillDownChildSWF.swf?ibiFilterDefault='+DrillDownValue;
        navigateToURL(new URLRequest(url));
      }
     ]]>
  </mx:Script>
</mx:Application>


Example: Child Drill Down Application Using @ibiFilterDefault

In the child SWF file that is Adobe Flash Player compatible, only the data filtered based on the row value clicked in the parent SWF file that is Adobe Flash Player compatible will be displayed. The example also illustrates how you can retrieve the parameter value appended to the URL request to run the child SWF file that is Adobe Flash Player compatible and to verify the filtered result.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
      xmlns:ibi="http://www.informationbuilders.com" backgroundColor="#FFFFFF" >
  <ibi:ibiCanvas id="pc" width="962" height="666" x="10" y="10">
    <mx:Label x="10" y="10" text="Data is filtered based on the value selected..." 
        fontSize="12" fontWeight="bold" width="370"/>
    <ibi:ibiDataGrid width="579" height="245" x="10" y="38"
        seturl="http://localhost:8080/ibi_apps/WFServlet?
                IBIF_ex=centurysales&amp;IBIAPP_app=ibiflexdemo"
        ibiUseColumns="PLANTREGION,STATE,CITY,STORENAME,Sum.PROFIT"
        ibiGroupBy="PLANTREGION,STATE,CITY,STORENAME"
        id="dg1" 
        ibiFilterDefault="@ibiFilterDefault"/>
    <mx:Label x="10" y="302" text="Show ibiFilterDefault value"
        fontSize="12" width="176"/>
    <mx:TextInput id="param_name" x="10" y="330" width="185" height="28" 
        text="ibiFilterDefault" />
    <mx:Button x="10" y="366" height="33" width="185"
        label="Display Parameter Value" click="retrieve_param_values()" />
    <mx:TextArea id="param_val" x="203" y="312" height="87"/>
  </ibi:ibiCanvas>
  <mx:Script>
     <![CDATA[ 
      import mx.events.ListEvent;
      import mx.events.ItemClickEvent;
      private function retrieve_param_values():void
      {
        var search:String = param_name.text;
        param_val.text = pc.getCustomParam(search);
        // this is provided to show an example on how you can
        // search through the array of parameters (ibiFilterDefault)
        // and retrieve value passed down such as "CITY EQ New York City"
      }
     ]]>
  </mx:Script>
</mx:Application>

When the user clicks on Consumer Merchandise in the Store Name column in the Parent SWF file that is Adobe Flash Player compatible, the ibiFilterDefault value “STORENAME EQ Consumer Merchandise” is passed to the child application and results in the following.


WebFOCUS