I am trying to access the data created from CArrayDataProvider - the view shows the data correctly as you need to access the data as an array rather than an object. The problem I am having is accessing the data in the ButtonColumn.
In the following view the dataProvider is a CArrayDataProvider.
$this->widget('bootstrap.widgets.TbGridView', array(
'type' => 'striped bordered condensed',
'dataProvider' => $dataProvider,
'ajaxUpdate'=>false,
'enablePagination'=>true,
'summaryText'=>'Displaying {start}-{end} of {count} results.',
'template' => "{summary}{items}{pager}",
'htmlOptions'=>array('style' => 'width:500px;margin-left: 130px;',),
'columns' => array(
array('name' => 'name', 'header'=> 'Trading Name',
'type'=>'raw',
'value'=>'CHtml::encode($data["name"])',
),
That all works fine - the problem is accessing the data ButtonColumn. I have tried many permutations to try to get the data. The line of code that is the problem is
'url'=>'"/DCompliance/index.php?r=admin/view_detail_edit_smcontractor&id=".$data["pk"]."', //or tried
'url'=>'"/DCompliance/index.php?r=admin/view_detail_edit_smcontractor&id=$data[\'pk\'']"',
The button column at moment is
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
......
'buttons'=>array
(
'view' => array
(
'label'=>'View Person',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/view.png',
'url'=>'"/DCompliance/index.php?r=admin/view_detail_edit_smcontractor&id=$data[\"pk\"]"',
),
How do I write the url to include the $data[‘pk’] of the array?