ddautofilter Display auto-filter popup dialogs in a CGridView similar to MS Excel auto-filters.

  1. Screenshots
  2. Installation
  3. Setup
  4. Discussion
  5. History
  6. Donate?

DDAutoFilter is a Yii extension to display auto-filters in a CGridView similar to MS Excel auto-filters.

It is currently working with Yii-bootstrap based Yii applications.

Screenshots

See bitbucket wiki.

Installation

Download or clone from bitbucket under protected/extensions/diggindata, so that you have a folder protected/extensions/diggindata/ddautofilter.

Setup

Model Behavior

In your model's behaviors method, add the DDAutoFilterSearchBehavior:

public function behaviors(){
    return array(
        ...
        'autoFilterSearchBehavior' => array(
            'class' => 'ext.diggindata.ddautofilter.DDAutoFilterSearchBehavior',
        ),
        ...
    );
}
Model / search Method

In your CActiveReord model's search() method, for each column that shall be displayed using auto-filters, change the $criteria line.

// Replace:
$criteria->compare('title',$this->title,true);
// ... with:
$criteria->mergeWith($this->textSearchCriteria('title', $this->title));

For date columns, use:

$criteria->mergeWith($this->dateSearchCriteria('title', $this->title));

For timestamp columns, use:

$criteria->mergeWith($this->dateSearchCriteria('title', $this->title, 'U'));
Grid View
Grid View Properties

Add some code to the CGridView afterAjaxUpdate property:

<?php $this->widget('ext.bootstrap.widgets.TbGridView', array(
    'id'=>'your-model-grid', // see below
    ...
    'afterAjaxUpdate'=>'function(){jQuery("i.autofilter").click(showAutofilterDialog)}',
    ...
    )); ?>
Grid View Columns
'columns' => array(
        ...
        array(
            'name'=>'level',
            'class'=>'ext.diggindata.ddautofilter.DDAutoFilterDataColumn',
            'columnType'=>'number', // or 'text' or 'date' or 'bool'
            'filter => array(1=>1, 2=>2, 3=>3), // will be displayed in values select multiple control
        ),
        ...
Auto-Filter Widget

After the CGridView widget code, add:

<?php $this->widget('ext.diggindata.ddautofilter.DDAutoFilterWidget', array('gridId' => 'your-model-grid')); ?>

Discussion

See Yii Extensions Forum Thread.

History

  • V0.1: (2013-05-06) Initial version

Donate?

If you like this extension, please consider donating a bit:

Donate with PayPal

4 0
11 followers
0 downloads
Yii Version: Unknown
License: BSD-2-Clause
Category: User Interface
Developed by: jwerner
Created on: May 6, 2013
Last updated: 11 years ago

Related Extensions