Hi All,
In my view I have a CGridView with an ajax link that loads another CGridView from a controller action:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'chart-list',
'dataProvider'=>$dataProvider
,'columns' => array(
'fname'
, 'lname'
, 'grade'
, 'age'
,array(
'name' => 'Charts',
'value' => 'CHtml::ajaxLink("List Charts", array("student/Ajaxcontent", "student_id"=>$data["id"]),
array("update" => "#stu_charts"))',
'type' => 'raw',
)
, array(
'class' => 'CButtonColumn'
, 'viewButtonUrl' => 'Yii::app()->createUrl("/Student/view", array("id"=>$data["id"]))'
, 'updateButtonUrl' => 'Yii::app()->createUrl("/Student/update", array("id"=>$data["id"]))'
, 'deleteButtonUrl' => 'Yii::app()->createUrl("/Student/delete", array("id"=>$data["id"]))'
))
)
);
<div id="stu_charts"></div>
<div id="show_chart"></div>
Here is the controller code:
public function actionAjaxcontent($student_id) {
echo "<span style='font-size: 2em';>$name $lname:</span>";
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'chart-grid',
'dataProvider' => $dataProvider
, 'columns' => array(
'chart_title'
, 'id'
, 'chart_date'
, 'student_id'
, array(
'name' => 'Show',
'value' => 'CHtml::ajaxLink("Show Chart", array("student/Stuff", "student_id"=>$data["id"]),
array("update" => "#show_chart"))',
'type' => 'raw',
),
) ) );
}
public function actionStuff() {
echo "stuff";
}
The CGridView from the controller loads in the view fine, but the links it contains do not work.
I would like it to ultimatley show a renderPartial of another view using these links, right now I’m just trying to get it to echo the content of the actionStuff method in the div <div id=“show_chart”></div>
I have tried adding JQuery code to the view like this
Yii::app()->clientScript->registerScript('ajaxupdate', "
$('#chart-grid a.ajaxupdate').live('click', function() {
$.fn.yiiGridView.update('chart-grid', {
type: 'POST',
url: $(this).attr('href'),
});
return false;
});
");
and adding the ajaxupdate class to the ajax link in the second CGridView, but no luck.
Appreciate any help
Thanks