Update Cgridview Via Ajax Button Not Working.

Hi all,

I’m trying to update a cgridview using a drop-down to select categories and an ajax button to submit the value to a controller for processing.

I have in my controller:

public function actionFilterClients {

    if (Yii::app()->request->isAjaxRequest) {

        if (isset($_POST['category_id'])) {

            $criteria = new CDbCriteria;

            $criteria->condition = "user_id=:user_id";

            $criteria->params = array(':user_id' => Yii::app()->user->id);


            $dataProvider = new CActiveDataProvider('Client', array(



            $this->renderPartial('transfer_step_3' , array('dataProvider'=>$dataProvider)) ;




In my view among other things I have:

<?php $filter=$this->beginWidget('CActiveForm', array(




        )); ?>

        <label for="category_id">View clients in category:</label>

        <?php echo CHtml::dropDownList('category_id','',Client::clientCategories(), array('options' => array('2'=>array('selected'=>true)))); ?>


            echo CHtml::ajaxButton(

                'Filter Clients',




                    'update'  => 'client-grid' ,

                    'success' =>"function(data) {





        <?php $this->endWidget(); ?>


<?php  $this->widget('bootstrap.widgets.TbGridView',array(

            'type'=>'bordered striped condensed',


            'ajaxUpdate' => true ,

            'rowCssClassExpression'=>'($data->duplicate==2)?"yellow"<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />$data->duplicate==1?"blue":"")',















                    'name' => 'category_title',

                    'type' => 'raw',

                    'value' => '$data->category->title',



        )); ?>

Because this is a multi-step form, the cgridview dataprovider defaults to listing all clients ($clients->moveclients() lists all clients).

The ajax button posts the category_id to the client/filterclients url correctly.

I can see with firebug that actionFilterClients returns the rendered html correctly (with the correct clients) but the gridview is not updated…

Any ideas on why not?

Thanks in advance!


can you add this in tbgridview and check

'afterAjaxUpdate'=>'function(id, data){



I hope it will solve your problem :)