Hi guys,
i guess i’ve found a bug coming up in similar situations like the following, would be useful if someone could confirm.
In a view ("index"), i build a simple menu what loads an another view ("_browse") by ajax through the action "browse", displaying a CGridView listing the records in my models.
foreach ($this->module->models as $m) {
echo CHtml::ajaxLink($m, $this->createUrl('default/browse', array(
'_modelname' => $m
)), array(
'update' => '#browsecontainer'
)
) . " ";
}
?>
<div id="browsecontainer">
<% $this->renderPartial('_browse'); %>
</div>
Here is the "browse" action in my controller:
public function actionBrowse() {
if (@$_REQUEST['_modelname']) {
$this->modelname = $_REQUEST['_modelname'];
$model = new $this->modelname("search");
$model->unsetAttributes();
if (@$_REQUEST[$this->modelname])
$model->attributes = $_REQUEST[$this->modelname];
$this->renderPartial('_browse', array(
'modelname'=>$this->modelname,
'model'=>$model,
'rows'=>$model->search(),
'columns'=>array_merge(
array_keys($model->getTableSchema()->columns),
array(
array(
'class' => 'CButtonColumn'
)
)
)
),false,true);
}
Yii::app()->end();
}
In the view "_browse", there is a CGridView instance, using the variables filled in the "browse" action:
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'mymodelbrowser_' . $modelname,
'filter' => $model,
'dataProvider' => $rows,
'columns' => $columns,
'enablePagination' => true
));
?>
The issue is, when i click an ajaxLink in the "index" view named eg. "Entity", then click an another model link eg. "Feature" then clicking back to the "Entity", the javascript onchange handler seems like called twice and two GET will be sent when using a filter field above a column (Firebug used). Navigating away again from the "Entity" GridView and back again, the filtering GET will be send already 3 times, away and back again results 4 GET/one filtering etc etc. However the filtering works, it should be a bug, i guess the CGridView widget is not properly cleaned up/reseted on the client side when rendering again.
Regards
nlac