article

Saturday, March 22, 2014

How to make CGridview with dropdown filter

How to make CGridview with dropdown filter


 
$this-<widget('zii.widgets.grid.CGridView',array(
   'dataProvider'=<$model-<search(),
   'id'=<'risk-id',
   'filter'=<$model,
   'columns'=<array(
   array(
      'name'=<'No',
      'type'=<'raw',
      'value'=<'$this-<grid-<dataProvider-<pagination-<currentPage*$this-<grid-<dataProvider-<pagination-<pageSize + $row+1',//this for the auto page number of cgridview
      'filter'=<''//without filtering 
   ),
   array(
      'name'=<'name',
      'type'=<'raw',
      'value'=<'Chtml::link(Chtml::encode($data["name"]),array("risk/view","id"=<$data["risk_id"]))',
      'filter'=<CHtml::listData(Risk::model()-<findAll(
                  array(
                   'select'=<array('name'),
                   'distinct'=<true
                    
                  )),"name","name")//this is the focus of your code
       
   ),
   array(
      'name'=<'date_identified',
      'type'=<'raw',
      'value'=<'Chtml::encode($data-<date_identified)'
   ),
   array(
      'name'=<'description',
      'type'=<'raw',
      'value'=<'Chtml::encode($data-<description)'
   ),
   array(
      'name'=<'type',
      'type'=<'raw',
      'value'=<'Chtml::encode($data-<type)',
       
   ),
   array(
      'name'=<'link',
      'type'=<'raw',
      'value'=<'$data-<link'
   ),
    
 
)
));

Related Post