Yii从dropDownList更新数据库

i try without success to update the database from a dropDownList of a CGridView.

here is the code of the CGridView:

<?php $this->widget('zii.widgets.grid.CGridView', array(
'id' => 'invoice-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(     

    'id',

    'username',

       array(
            'name'  => 'state',
            'type'  => 'raw',
            'value' => '$data->stateDropdown',
            'filter' => array('0' => Yii::t('app', 'No'),
                              '1' => Yii::t('app', 'Yes'),
                             ),
       ),

    array(
        'class' => 'CButtonColumn',
        'template'=>'{view}',
    ),
),
)); ?>

Here is the getter of the function stateDropDown() in the Model:

public function getStateDropdown()
{
    $state = array(
            0 => 'No',
            1 => 'Yes',
    );
    return CHtml::dropDownlist('state', $this->state, $state, array(
            'class'    => 'state',
            'data-id'  => $this->id,
            'onchange' => 'alert(0);',
    ));
}

When I change the dropDownList element, the alert script is triggered, but when i try to use a function instead, i have an error. I want to use this function described below to update the value of state in the database.

function updateState($state, $id)
{
$user = User::model()->findByPk($id);
$user->state = $state;
$user->update();
}

How can i really call the function updateState() in place of alert(0)

quick answer: use x-editable extension, which has done an impressive job

other wise, you have to build something exactly like that,

make user select an item from your list, then make ajax request to save that change