I have the following view file:
<div class="search-form">
<?php $model2 = new Symptoms;
$this->renderPartial('_searchCategory', array('model'=> $model2), false, true); ?>
</div>
<div class="row" id="symptomSelectDiv" >
<?php
$this->renderPartial('_symptomsGrid', array('model'=> $model2));
?>
</div>
The 2 subviews are
_searchCategory:
<?php
echo CHtml::dropDownList('symptomCategory', 'symptomCategory',
$this->getSymptomCategories(),
array('id'=>'categorySelectDropDown',
'prompt'=>"Select Symptom Category",
'ajax'=> array(
'type'=>'POST',
'url'=>Yii::app()->createUrl('symptomhistory/updateSymptomsGridView'),
'replace'=>'#symptoms-grid',
'data'=>array('symptomCategory'=>'js:this.value', 'YII_CSRF_TOKEN' => Yii::app()->request->csrfToken))
));
?>
And
_symptomsGrid:
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'symptoms-grid',
'selectableRows'=>1, //ability to select one symptom at a time
'dataProvider'=>$model->searchCategory(),
'columns'=>array(
'symptomCode',
'title',
'inclusions',
'exclusions',
'symptomCategory',
)
)); ?>
The controller action that replaces the grid with the new one is:
public function actionUpdateSymptomsGridView()
{
$symptomsModel = new Symptoms;
if(isset($_POST['symptomCategory']))
{
$symptomsModel->setAttributes(array(
'symptomCategory'=>$_POST['symptomCategory']));
$this->renderPartial('_symptomsGrid', array('model'=>$symptomsModel), false, true);
}
}
The problem is that when the new gridview loads and I go to a different page of its pagination it doesn’t load and instead I lose the entire gridview (I checked my html with firebug, there’s nothing being rendered).
Can anyone help me please?