Hi there,
I’m a newcomer to Yii and have searched around for quite some time trying to find how to hide the CButtonColumn of a CGridView if the logged in user is not admin.
What’s the best way to go about it?
I basically want to run this code if user is admin…
    $this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'result-grid',
        'dataProvider'=>$dataProvider,
        'filter'=>$model,
        'columns'=>array(
            'datePlayedFormatted:text:Date Played',
            'winner.fullName:text:Winner',
            'matchResultText:text:Match Result',
            'loser.fullName:text:Loser',
            'gameScores:text',
            array(
                'class'=>'CButtonColumn',
            ),        
        ),
    ));
…and this code otherwise (i.e. ommitting the column which allows you to act on individual rows)…
    $this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'result-grid',
        'dataProvider'=>$dataProvider,
        'filter'=>$model,
        'columns'=>array(
            'datePlayedFormatted:text:Date Played',
            'winner.fullName:text:Winner',
            'matchResultText:text:Match Result',
            'loser.fullName:text:Loser',
            'gameScores:text',
        ),
    ));
Ideally I’d like to know the best practice recommendation for this kind of thing, rather than a quick and dirty non-standard solution.
Any advice would be much appreciated.