incendium
(Townie Rettie)
February 24, 2014, 10:28am
1
Hello,
I’m using the standard yii code for searching and updating a yii grid view:
$('.search-form form').submit(function(){
$('#item-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
The search form consists of two dropdown fields. The problem: The content of dropdown two depend on the selected value in dropdown one.
I implemented this in php, but the problem is, that the piece of jquery code above updates just the grid view. Is there a possibility to also update the search form? The ajax calls gets the whole html code, so I guess this is possible.
Any ideas?
Hi,
In search method , you should set the value which has been selected previously…
Then it will be selected on your next call
bagwari65
(Manish)
February 24, 2014, 1:18pm
3
hi,
In your grid view use filer …
$this->widget('zii.widgets.grid.CGridView', array(
'itemsCssClass' => ' ',
'dataProvider'=>$model->search(),
'filter'=>$model,
'id'=>'user-grid',
'columns'=>array(
//your filds
));
$this->endWidget();
and in ur controller’s action just do this…
public function actionActionName()
{
$dataProvider=new CActiveDataProvider('Your_Model',array(
'sort'=>array(
'defaultOrder'=>'date_created DESC',
)
)
);
$model=new YourModel('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['YourModel']))
$model->attributes=$_GET['YourModel'];
$this->render('index',array(
'dataProvider'=>$dataProvider,'model'=>$model,
));
}