Yii Framework Forum: Filter In Tbgridview - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Filter In Tbgridview Rate Topic: -----

#1 User is offline   Javed Iqbal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 25-October 11

Posted 19 March 2014 - 10:34 AM

Hi
I have used CHOSEN extension in TbGridview filter.When first time page load then CHOSEN extension is working fine but whenever I change value from CHOSEN dropdownlist then normal dropdownlist is showing (i can search in dropdowlist items).

admin.php
Yii::import('ext.chosen.Chosen');
$this->widget('bootstrap.widgets.TbGridView', array(
    'type'=>'striped bordered condensed',
    'dataProvider'=>$model->search(),
    'template'=>"{items}{pager}",
	'filter'=>$model,
    'columns'=>array(
        array('name'=>'id', 'header'=>'Product ID'),
    		array('name'=>'name', //'header'=>'Type',
    				'filter' => CHtml::listData(Products::model()->findall("edt IS NULL ORDER BY name"), 'id', 'name'),
    		),
    		array('name'=>'specifications'),
    		//array('name'=>'PT.product_type', 'header'=>'Type'),
    		array('name'=>'ptype', //'header'=>'Type',
    				'value'=>'ProductType::model()->findByPk($data->ptype)->product_type',
    				'filter' => Chosen::activeDropDownList($model, "ptype", CHtml::listData(ProductType::model()->findall("edt IS NULL ORDER BY product_type"), 'id', 'product_type'))
    				),
    		array(
            'class'=>'bootstrap.widgets.TbButtonColumn',
            'htmlOptions'=>array('style'=>'width: 50px'),
        		//'template'=>'{view}{update}{delete}',
        		'buttons'=>array(        				
        				'delete' => array(
        						//'url'=>'Yii::app()->controller->createUrl("ports/delete", array("id"=>$data[id],"command"=>"delete"))',
								'visible'=>'false'
        				),
        		),
        ),//*/
    ),
));

Javed Iqbal

Web Developer
syntecX Solution
skype:javedboqo
0

#2 User is offline   Javed Iqbal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 25-October 11

Posted 19 March 2014 - 11:31 AM

View PostJaved Iqbal, on 19 March 2014 - 10:34 AM, said:

Hi
I have used CHOSEN extension in TbGridview filter.When first time page load then CHOSEN extension is working fine but whenever I change value from CHOSEN dropdownlist then normal dropdownlist is showing (i can search in dropdowlist items).

admin.php
Yii::import('ext.chosen.Chosen');
$this->widget('bootstrap.widgets.TbGridView', array(
    'type'=>'striped bordered condensed',
    'dataProvider'=>$model->search(),
    'template'=>"{items}{pager}",
	'filter'=>$model,
    'columns'=>array(
        array('name'=>'id', 'header'=>'Product ID'),
    		array('name'=>'name', //'header'=>'Type',
    				'filter' => CHtml::listData(Products::model()->findall("edt IS NULL ORDER BY name"), 'id', 'name'),
    		),
    		array('name'=>'specifications'),
    		//array('name'=>'PT.product_type', 'header'=>'Type'),
    		array('name'=>'ptype', //'header'=>'Type',
    				'value'=>'ProductType::model()->findByPk($data->ptype)->product_type',
    				'filter' => Chosen::activeDropDownList($model, "ptype", CHtml::listData(ProductType::model()->findall("edt IS NULL ORDER BY product_type"), 'id', 'product_type'))
    				),
    		array(
            'class'=>'bootstrap.widgets.TbButtonColumn',
            'htmlOptions'=>array('style'=>'width: 50px'),
        		//'template'=>'{view}{update}{delete}',
        		'buttons'=>array(        				
        				'delete' => array(
        						//'url'=>'Yii::app()->controller->createUrl("ports/delete", array("id"=>$data[id],"command"=>"delete"))',
								'visible'=>'false'
        				),
        		),
        ),//*/
    ),
));




I have added 'afterAjaxUpdate' => 'applyChosen', in the widget and register following script and my problem solved.
Yii::app()->clientScript->registerScript('apply-Chosen', "function applyChosen(id, data) { $('select.chosen').data('placeholder','Select option').chosen(); }");

Javed Iqbal

Web Developer
syntecX Solution
skype:javedboqo
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users