Class actuate.data.Filter
Description
Specifies filter conditions to be used by other classes when processing data. A filter has three components: a column, an operator, and a value or set of values. The condition is expressed as "value1 operator value2". For some operators, like "IN", the expression will be "value1 IN value2" where value2 is an array of strings.
Format numbers and date/time values in a locale neutral format, for example "2.5" or "09/31/2008 01:02:03 AM".
Constructor
Syntax
actuate.data.Filter(string columnName, string operator, string[ ] value1, string[ ] value2)
Constructs a filter object.
Parameters
columnName
String. The column name.
operator
String. The operator can be any operator. Table 4-10 lists the valid filter operators and the number of arguments to pass to the constructor or setValues( ).
Table 4-10  
Number of
arguments
value1
String or array of strings. The first value to compare to the column value for the BETWEEN or NOT_BETWEEN operators.
value2
String or array of strings. This parameter is only required for the BETWEEN or NOT_BETWEEN operators.
Example
To select all of the rows matching a list of countries in their country fields, use code similar to the following:
var filter = new actuate.data.Filter("COUNTRY", actuate.data.Filter.IN,["Canada" , "USA", "UK", "Australia"]);
To create a filter to display only entries with a CITY value of NYC, use the following code:
var cityfilter = new actuate.data.Filter("CITY", actuate.data.Filter.EQ, "NYC");
Function summary
Table 4-11 lists actuate.data.Filter functions.
Table 4-11  
actuate.data.Filter.getColumnName
Syntax
string Filter.getColumnName( )
Returns the column name.
Returns
String. The name of the column.
Example
This example retrieves the name of the column:
function retrieveColumnName(myFilter){
  var colname = myFilter.getColumnName( );
  return colname;
}
actuate.data.Filter.getOperator
Syntax
string Filter.getOperator( )
Returns the filter operator.
Returns
String. Table 4-10 lists the legal filter operator values.
Example
This example retrieves the name of the filter operator:
function retrieveFilterOperator(myFilter){
  var myOp = myFilter.getOperator( );
  return myOp;
}
actuate.data.Filter.getValues
Syntax
string Filter.getValues( )
string[ ] Filter.getValues( )
Returns the evaluated results of this filter. When the filter is constructed or set with a single argument, the returned value corresponds to the single argument. When two arguments or an array are set in the filter, the return value is an array of values.
Returns
String or array of strings. Returns the value or values from the filter.
Example
This example retrieves the name of the filter operator:
function retrieveValues(myFilter){
  var myVals = myFilter.getValues( );
  return myVals;
}
actuate.data.Filter.setColumnName
Syntax
void Filter.setColumnName(columnName)
Sets the name of the column to filter.
Parameters
columnName
String. The column name.
Example
This example sets the name of the column to filter to Sales:
function setFilterSales( myfilter ){
  myfilter.setColumnName("Sales");
}
actuate.data.Filter.setOperator
Syntax
void Filter.setOperator(string operator)
Sets filter operator. The operator determines the comparison made between the data in the column and the value or values set in the filter.
Parameters
operator
String. The operator can be any valid operator. Table 4-10 lists the valid filter operators and the number of arguments to pass to Filter.setValues( ).
Example
This example sets the filter to retrieve the bottom five values:
function setFilterBot5( ){
  myfilter.setOperator("BOTTOM_N");
  myfilter.setValues("5");
}
actuate.data.Filter.setValues
Syntax
void Filter.setValues(string value)
void Filter.setValues(string value1, string value2)
void Filter.setValues(string[ ] values)
Sets string values for the filter to compare to the data in the column according to the operator. Table 4-10 lists the valid filter operators and the values they use. Takes either one or two values, or one array of values.
Parameters
value
String. The value to compare to the column value.
value1
String. The first value to compare to the column value for the BETWEEN operator.
value2
String. The second value to compare to the column value for the BETWEEN operator.
values
Array of strings. The values to compare to the column value for the IN operator.
Example
This example sets the filter to retrieve values between 10 and 35:
function setFilter( myfilter ){
  myfilter.setOperator("BETWEEN");
  myfilter.setValues("10","35");
}

Additional Links:

Copyright Actuate Corporation 2012