setFilterValue

sets a filter for a particular field

void setFilterValue(id id,object value);

Parameters

ididthe id of a field
valueobjectthe filter configuration object

Example

// setting a filter for a field with string values
pivot.setFilterValue("name",{
    operation:"ct",
    filter:"a",
    values:["Argentina","Australia"]
});
 
// setting a filter for a field with number values
pivot.setFilterValue("year",{
    operation:"gt"
    filter:"2005",
    values:[2006]   
});
 
// setting a filter for a field with date values
pivot.setFilterValue("when",{
    filter:{from:"01.03.2012",to:"01.05.2012"},
    values:[1336078800000]
});

Details

The filter configuration object contains the following properties:

  • operation - (string) the type of the filtering operation. It's set for filters that work with string and number values
  • filter - (string) the input value to compare with possible values of the field
  • values - (array) an array of data values matching to the input value

Setting filters for fields with date values

Note that there are some important points in setting filters for fields that work with date values.

  • the type of operation is not set for the filters of this type
  • the filter value is set and get as an object with from and to dates as properties
  • the filtering value/values must be specified in milliseconds
pivot.setFilterValue("when",{
    filter:{from:"01.03.2012",to:"01.05.2012"},
    values:[1336078800000]
});
  • you can set a custom format for entering dates via the inputFormat property of the corresponding date field:
fieldList: [
    { id: "name", label: "Name" },
    { id: "year", label: "Year", type: "number" },
    { id: "when", label: "When", type: "date", 
        format: "%d/%m/%Y", inputFormat: "%d.%m.%Y" }
    // more fields
]

Removing a certain filter

The setFilterValue() method also allows you to remove a particular filter by passing an empty object as a second parameter:

pivot.setFilterValue("name",{});
See also
Back to top