I have the following code on an index page which creates a dropdown with an ajax function
echo CHtml::dropDownList('','filter', CHtml::listData(Models::model()->findAll(array()), 'id', 'model'),array('empty' => Yii::t('app','misc.pleaseselect'),"onChange"=> CHtml::ajax(array("type"=>"POST","dataType"=>"json",
"url"=>array("Administration/showFiltersGrids"),
"data"=>array("model_id"=>"js: this.value"),
"success"=>"function(data){
$(\"#filtersarea\").html(data.gridViews);
}",
)
)
));
?>
Upon selection this uses an action to generate a data provider and then render partial a page that contains a CGridview, passing the data provider with it.
/*
** This is an ajax rendering of the filter field grid dependent on the posted data
*/
public function actionshowFiltersGrids()
{
$dataProvider = Filters::model()->dpAdministration($_POST['model_id']);
$gridViews[] = $this->renderPartial("_grid_filters", array('dataProvider' => $dataProvider), true);
echo CJSON::encode(array('gridViews'=>$gridViews));
}
This works perfectly fine and renders the gridview on every change of the dropdown. The issue I am having however, is that both sort and pagination result with Yii trying to load the page in which the grid is held. Resulting in a display like so
What I need Ideally is to make the sort function an ajax update, can someone point me in the right direction of how to solve this.