Hi, I’m new to yii and web programming.
I have a page set up like this :
-CGridView with a column containing the name of the item and another containing an ‘add’ button.
-Another CGridView, empty when you load the page
What I want to do is, when you click on the add button, the element next to the button is added to the second CGridView. How do I do that ? The items listed in the first CGridView are from a model, so I figured I should write a method in the controller linked to the said model. This is what I wrote in the controller file. (I’m kinda new to the MVC thing too.)
public function actionView($id)
{
$model = $this->loadModel($id);
if (yii::app()->request->isAjaxRequest)
{
echo CJavaScript::jsonEncode(array(
'id' => $model->id,
'nom' => $model->nom,
'critere_id' => $model->critere_id,
));
yii::app()->end();
}
else
throw new CHttpException(400,'Invalid request. This probably occured because you do not have Javascript enabled. Please enable Javascript!');
}
If I get it right, this sends Javascript data containing information about the clicked element.
But how do I get it to be displayed in the separate CGridView ?
Also, if I want all items of a CGridView stocked into an array, how can I do that ?
Any help is much appreciated, thanks