简体   繁体   English

如何在CgridView按钮中调用模型函数以获取Yii中的可见属性

[英]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. 不会为每行评估visible ,最后必须将其设置为true或false。 So to determine if current column is visible, you have to call single function from your view that returns true or false. 因此,要确定当前是否可见,您必须从返回true或false的视图中调用单个函数。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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