Ok I have 2 model classes that take part in this problem. I have a model class Symptoms and model class Symptomhistory.
I have a search form view for Symptomhistory which I need it to load a cgridview of Symptoms model active records. In the view file (which I repeat is rendered by the symptomhistory controller) I do renderPartial like this:
<div class="search-form">
<?php $model2 = new Symptoms; ?>
<?php $this->renderPartial('_searchCategory',array('model'=>$model2)); ?>
</div>
<!-- select symptom -->
<div class="row" id="symptomSelectDiv" >
<?php $this->renderPartial('_symptomsGrid',array('model'=>$model2, false, true));?>
</div>
The views code is:
_searchCategory:
<?php echo CHtml::dropDownList('symptomCategory',
'symptomCategory',
$$this->getSymptomCategories(),
array('id'=>'categorySelectDropDown',
'prompt'=>"Select Symptom Category")); ?>
getSymptomCategories returns the following array:
public static function getSymptomCategories()
{
return array(
'A' => 'A',
'B' => 'B',
//ect. ect., these aren't the real values just using them as an example
);
}
And the _symptomsGrid view has this code:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'symptoms-grid',
'selectableRows'=>1, //ability to select one symptom at a time
'dataProvider'=>$model2->searchCategory(),
'htmlOptions'=>array('id'=>'symptomsSelectGrid'),
'columns'=>array(
'symptomCode',
'title',
'inclusions',
'exclusions',
'symptomCategory',
),
)); ?>
The searchCategory function is the normal gii built search action with just the symptomCategory being compared.
Lastly my javascript function to update the gridview is this:
$('#categorySelectDropDown').change(function()
{
$('#symptomSelectDiv').show();
$('#symptoms-grid').yiiGridView('update',
{
data: $(this).serialize()
});
return false;
});
My problem is that when I change selection on the dropdown I still get the same result (ALL symptoms active records returned).
I think the problem might be that I am using a different model’s action’s in a different controller’s view, but I need to do that to use the gridview select as form input. Can someone help me please? I’m new and there’s some stuff that I just can’t find good enough documentation for online.
Thank you for your time