Hello,
I have on site combobox with values that represents dynamic table names. Below combobox I have CGridView with data from that tables (one at a time). When I choose one option from combobox, I want to refresh CGridView with data from other table.
In my action I have:
$sources = Sources::model()->find();
$values = Values::model()->setCollection($source_id);
And in View I have:
echo CHtml::dropDownList('source_id', $selected, CHtml::listData($sources, '_id', 'name'), [
'ajax' => [
'type' => 'POST',
'url' => Yii::app()->createUrl('values/value/selectValue'),
'data' => ['source_id' => 'js:this.value'],
'success' => 'function(data){
data = JSON.parse(data);
$("#value-grid").yiiGridView.update("value-grid");
}'
]
]);