fn.yiiGridView.update event not firing

admin

Administrator
Staff member
I am new to Yii. I have a dropdown list and a CGridView. The idea is that I want to filter the records shown in the gridview based on what the user selects on the dropdown list. I have read several tutorials, and almost all of them are pretty much like <a href="https://kakousis.wordpress.com/2013/05/11/dropdown-ajax-based-filtering-of-clistview-in-yii/" rel="nofollow">this one</a>.

Unfortunately, the code does not seem to fire the gridview update event.

Here is my code based on the tutorial

Controller

Code:
public function actionIndex()
{

        $criteria = (isset($_GET['id-dropdown'])) ?
                array(
                    'condition' =&gt; 'account = ' . $_GET['id-dropdown'],
                ): array();

        $options = array(
            'criteria' =&gt;$criteria,
            'pagination' =&gt; array(
                'pagesize' =&gt; 100,
            ),
        );
        $modelAccount = new Account();
        $dataProvider = new CActiveDataProvider('Jurnal', $options);

        $selected_account = (isset($_GET['id-dropdown'])) ? $_GET['id-dropdown']: '101'; //101 is the default

    $this-&gt;render('index', array(
                //'modelCustom'=&gt;$modelCustom,
'modelAccount'=&gt;$modelAccount, 
                'dataProvider'=&gt;$dataProvider,
                'selected_account' =&gt; $selected_account ));
}

This is my view

Code:
   &lt;?php 
Yii::app()-&gt;clientScript-&gt;registerScript('items_update', "$('#id-dropdown').change(function(){
        alert('ok'); //this works
        $.fn.yiiGridView.update('jurnal-grid', {
                type:'GET',
                data: $(this).serialize(),
                success=&gt;
                   js:function() { $.fn.yiiGridView.update('jurnal-grid');}
                }
            }
        );
    });
    return false;",
    CClientScript::POS_READY);
?&gt;
&lt;h1&gt;View Per Account&lt;/h1&gt;
&lt;div class="form"&gt;
&lt;?php

$form=$this-&gt;beginWidget('CActiveForm', array(
    'id'=&gt;'menu-dropdown-form',
    'enableAjaxValidation'=&gt;true,
));

echo $form-&gt;labelEx($modelAccount, $selected_account);
$criteria = new CDbCriteria();
$criteria-&gt;order = 'id ASC';
$account = Account::model()-&gt;findAll($criteria);
$accountlist = CHtml::listData($account, 'id', 'description');
echo CHtml::dropDownList('id-dropdown', '$selected_account', $accountlist);
$this-&gt;endWidget();

?&gt;
&lt;/div&gt;
&lt;?php
$this-&gt;widget('zii.widgets.grid.CGridView', array(
    'id' =&gt; 'jurnal-grid',
    'dataProvider'=&gt;$dataProvider,
    'columns' =&gt; array(
        'tanggal',
        'account',
        array(
            'class' =&gt; 'CButtonColumn',
        ),
    ),
));
?&gt;

Please help me, thank you in advance