Actuate JavaScript API classes : Class actuate.data.Filter

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-9 lists the valid filter operators and the number of arguments to pass to the constructor or setValues( ).

Table 4-9  Filter operators
Matches the bottom percent of the values
Does not match any value in a set of values
Search for values that do not match a pattern

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. The second value to compare to the column value 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-10 lists actuate.data.Filter functions.

actuate.data.Filter.getColumnName

Syntax

string Filter.getColumnName( )

Gets the column name.

Returns

String.

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( )

Gets the filter operator. Table 4-9 lists the legal filter operator values.

Returns

String.

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 value or values of the filter. When a single argument is passed to getValues( ), the returned value corresponds to the single argument. When two arguments or an array are passed to getValues( ), the return value is an array of values.

Returns

String or array of Strings

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( ){
  return myfilter.setColumnName("Sales");
}

actuate.data.Filter.setOperator

Syntax

void Filter.setOperator(string operator)

Sets filter operator. The operator determines the comparison to make between the data in the column and the value or values set in the filter. Table 4-9 lists the possible values.

Parameters

operator

String. The operator can be any operator. Table 4-9 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-9 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 setFilter1035( ){
  myfilter.setOperator("BETWEEN");
  myfilter.setValues("10","35");
}

(c) Copyright Actuate Corporation 2011