Skip to content

Instantly share code, notes, and snippets.

@umidjons
Created December 5, 2013 09:03
Show Gist options
  • Save umidjons/7802282 to your computer and use it in GitHub Desktop.
Save umidjons/7802282 to your computer and use it in GitHub Desktop.
Yii: CGridView column with drop-down filter
<?php $this->widget( 'zii.widgets.grid.CGridView', array(
'id' => 'product-2-group-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'summaryText' => '{start} - {end} / {count}',
'selectableRows' => 2,
'columns' => array(
array(
'name' => 'product_code',
'htmlOptions' => array( 'class' => 'product_code' ),
),
array(
'name' => 'product_name',
'htmlOptions' => array( 'class' => 'product_name' ),
),
array(
'name' => 'group_title',
'htmlOptions' => array( 'class' => 'group_title' ),
'filter' => CHtml::dropDownList( 'VwProductsList[group_title]', $model->group_title,
CHtml::listData( ProductGroups::model()->findAll( array( 'order' => 'group_title' ) ), 'group_title', 'group_title' ),
array( 'empty' => '-' )
),
),
),
) ); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment