Module Filter¶
Class Vtiger_Filter provides API to work with a Module’s custom view or filter. The list view display is controlled via these filters.
The example given below describes the way of creating new filter for the module:
include_once('vtlib/Vtiger/Module.php');
$filterInstance = new Vtiger_Filter();
$filterInstance->name = 'All';
$filterInstance->isdefault = true;
$moduleInstance->addFilter($filterInstance);
Configure fields¶
To add fields to the filter you can use the following API:
$filterInstance->addField($fieldInstance, $columnIndex);
Where $columnIndex (optional) is the order/index at which the field should appear in the list view.
Setup Rules¶
Once the field is added to filter you can setup rule (condition) for filtering as well using the following API:
$filterInstance->addRule($fieldInstance, $comparator, $compareValue, $columnIndex);
Where comparator could be one of the following:
EQUALS |
NOT_EQUALS |
STARTS_WITH |
ENDS_WITH |
CONTAINS |
DOES_NOT_CONTAINS |
LESS_THAN |
GREATER_THAN |
LESS_OR_EQUAL |
GREATER_OR_EQUAL |
$compareValue is the value against with the field needs to be compared.
$columnIndex (optional) is the order at which this rule condition should be applied.