I’ve been trying to get a CGridView to ajax itself. The problem is, I’, using an ajaxed container that has some elements in addition to the CGridView.
I’ve made an action that outputs the grid only that looks like this:
public function actionGetGridView()
{
$dataProvider = new CActiveDataProvider('Test');
$this->renderPartial(
'gridView',
array(
'dataProvider' => $dataProvider,
),
false,
true
);
}
Inside the ‘gridView’ view, I use code like this:
$this->widget(
'zii.widgets.grid.CGridView',
array(
'ajaxUrl' => Yii::app()->createAbsoluteUrl('site/getGridView'),
'dataProvider'=> $dataProvider,
'columns' => array(
'col1',
'col2',
'col3',
),
'summaryText' => ''
)
);
When I go to the action directly it works great, but when I renderPartial() the action in ajaxed content, like this:
$dataProvider = new CActiveDataProvider('Test');
$this->renderPartial(
'gridView',
array(
'dataProvider' => $dataProvider,
),
false,
true
);
it just redirects the entire page to the action that generated the entire ajaxed content, including the extra form elements. It seems like the ajaxUrl property is not working, and I’m not sure what to do. I know there’s some javascript that gets loaded dynamically and won’t be loaded on ajax, but I’ve tried to manually load it and it still doesn’t work. Maybe I’m missing something?
Help!