You can add multiple filters on top of an AutoGrid. Change the filters by setting the _filters member variable of the AutoGrid controller.

Defining your filters can be done in any subclass from Kwf_Controller_Action_Auto_Abstract.

The best way is to define them in preDispatch-function before calling parent::preDispatch() or if you define them directly via

protected $_filters = followed by your filter-definitions


The simplest filter is a text filter that searches all displayed columns by default.

//default text filter:
       $this->_filters = array('text' => true);

       //optionally define fields that should be search, defaults to all columns
       $this->_queryFields = array('foo');

       //text filter with custom settings:
       $this->_filters = array('text' => array(
           'type' => 'TextField',
           'width' => 90,
           'label' => 'Filter:',
           'queryFields' => array('foo', 'bar'), //search those fields


$this->_filters = array('active' => array(
    'type' => 'Button'
    'text' => 'Only Active:',


If no data is provided it's working with the model set for controller and querying for the key used for filter in filter-array.

  $this->_filters = array('type' => array(
      'type' => 'ComboBox',
      'label' => trl('Type'),
      'data' => array(
      'skipWhere' => true

Date & DateRange

Additionally there are filters for Date and DateRange.

Change filtering

If you want custom logic in your controller you first have to disable the default filtering by adding skipWhere:

$this->_filters = array('inactive' => array(
    'type' => 'Button'

and then implement your own logic in the controller:

protected function _getSelect()
    $ret = parent::_getSelect();
    if ($this->_getParam('query_inactive')) {
        //show only inactive
        $ret->whereEquals('active', false);
    } else {
        //show only active by default
        $ret->whereEquals('active', true);
    return $ret;

Filter Class

class MyFilter extends Kwf_Controller_Action_Auto_Filter_ComboBox
    protected function _init()
        $this->setLabel('My Filter:');
        $data = array();
        //$data[] = array('ID', 'DisplayText');
        $data[] = array('1', 'Value 1');
        $data[] = array('2', 'Value 2');

    public function formatSelect($select, $params = array())
        if (isset($params['query_column1'])) {
            $column1 = $params['query_column1'];
            //configure the select object
        return $select;