Yii Framework Forum: Access $Data Array In Carraydataprovider - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Access $Data Array In Carraydataprovider In ButtonColumn Rate Topic: -----

#1 User is offline   Anthony Gough 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 29-October 12

Posted 02 April 2014 - 10:11 PM

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?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users