简体   繁体   中英

How to calling model function in cgridview button for visible property in yii

How to solve problem?

array(
        'header'=>'Manage',
        'class'=>'CButtonColumn',
        'template'=>'{Manage}',
        //'visible'=>'$data->checkSub($data->sub_id)', //it not work not call function
                'visible'=>Model::test(), //it works

        'buttons'=>array(
                'Manage Exam Result'=>array(
                            'label'=>'<i class="fa fa-cogs"></i>',

                        ),
                ),
        ), 
),

visible is not evaluated for each row, it must be set to true or false in the end. So to determine if current column is visible, you have to call single function from your view that returns true or false.

[
    ...
    'visible' => Model::checkIfVisibleColumn(),
    ...
],
array(
  'class'=>'CButtonColumn',
                 'buttons'=>array(
                            'manage' => array('visible' => 'name_function($data->id)'),
                  ),
            ),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM