【问题标题】:Yii2 GridView checkbox apply selected classYii2 GridView 复选框应用选定的类
【发布时间】:2016-04-20 18:38:52
【问题描述】:

当复选框被选中时,如何在 Yii2 Gridview 行上应用选定的类。

 GridView::widget([
    'tableOptions' => ['class' => 'table table-striped table-hover'],
    'dataProvider' => $dataProvider,
    'layout' => "{items}<div class='row'><div class='pull-left'> \n {summary}</div><div class='pull-right'>{pager}</div></div>",

    'columns' => [
      //  ['class' => 'yii\grid\SerialColumn'],
        [
            'class' => 'yii\grid\CheckboxColumn',
            'checkboxOptions' => function($model, $key, $index, $column) {
                  return ['value' => $model->jobid];
            }

        ],

【问题讨论】:

  • 这个问题有新的答案。

标签: yii2


【解决方案1】:

这段代码对我有用。

将 onClick 事件绑定到复选框,例如:

$("input[type='checkbox']").click(function(e){
if ($(this).is(':checked')){
   $(this).parent().parent().addClass('alert-success');
} else {
   $(this).parent().parent().removeClass('alert-success');
}
})

显然 (.parent()) 周围的确切代码将取决于您的 DOM 结构。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-17
    • 2018-02-11
    • 2019-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-25
    相关资源
    最近更新 更多