dazbarlby
(Daryl)
November 27, 2010, 1:32pm
1
I must be doing something wrong, I needed to add pid to the update button within CButtonColumn but when I did this it removed the row id of the active record so I added id with ‘id’=>’$data->id’ but it doesn’t output the id.
Does anybody know where I’m going wrong?
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'issue-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'name',
'description',
'project_id',
'type_id',
'status_id',
/*
'owner_id',
'requester_id',
'create_time',
'create_user_id',
'update_time',
'update_user_id',
*/
array(
'class'=>'CButtonColumn',
'updateButtonUrl'=>"Yii::app()->createUrl('issue/update', array('id'=>'$data->id', 'pid'=>'$model->project_id'))",
)
),
)
);
dazbarlby:
I must be doing something wrong, I needed to add pid to the update button within CButtonColumn but when I did this it removed the row id of the active record so I added id with ‘id’=>’$data->id’ but it doesn’t output the id.
Does anybody know where I’m going wrong?
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'issue-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'name',
'description',
'project_id',
'type_id',
'status_id',
/*
'owner_id',
'requester_id',
'create_time',
'create_user_id',
'update_time',
'update_user_id',
*/
array(
'class'=>'CButtonColumn',
'updateButtonUrl'=>"Yii::app()->createUrl('issue/update', array('id'=>'$data->id', 'pid'=>'$model->project_id'))",
)
),
)
);
Try this
createUrl(‘issue/update’, array(‘id’=>’$data->id’), ‘&pid=$model->project_id’)
dazbarlby
(Daryl)
November 27, 2010, 2:08pm
3
Thanks Thirumalai, but it’s still only showing the pid and not the id of the row.
Can you see anything obvious I’m missing?
dazbarlby
(Daryl)
November 28, 2010, 2:28pm
4
[SOLVED]
The problem was caused because I was trying to access pid through $model when I should have been accessing it through $data as $model had been passed to the widget. See code below.
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'issue-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'name',
'description',
'project_id',
'type_id',
'status_id',
array(
'class'=>'CButtonColumn',
'updateButtonUrl'=>'Yii::app()->controller->createUrl("update",array("id"=>$data->primaryKey, "pid"=>$data->project_id))'
),
),
)
);
?>