【问题标题】:Check box as a header in yajra datatable复选框作为 yajra 数据表中的标题
【发布时间】:2016-10-18 22:32:48
【问题描述】:

是否可以使用 addColumn 函数将复选框设置为 yajra 数据表中的标题。

 ->editColumn('message', function ($data) {
            return '<a href="' . route('messages.show', [$data->id]) . '" style="color:#333;text-decoration:underline">' . $data->message . '</a>';
        })

在编辑列中,第一个参数是字符串('message'字符串作为标题)。我想在 yajra 数据表中使用 addColumn 将复选框作为标题。

【问题讨论】:

    标签: javascript laravel datatables laravel-5.2


    【解决方案1】:

    在数据表中

    private function getColumns()
    {
        return [
            'id' => ['name' => 'id', 'data' => 'id', 'style' => 'width:90%' , 'class'=>'msg']
               ];
    }
    

    编辑栏

     ->editColumn('id', function ($data) {
                return '<input type="checkbox" class="group-checkable" value="'.$data->id.'">';
            })
    

    在刀片中:

     <script>
        var htmlstr = '<input type="checkbox" id="checkAll"/> ';
        $('.msg').html(htmlstr)
     </script>
    

    在数据表中使 Orderable 为 false

    $this->getColumns(),
                [
                    'id' => [
                        'orderable' => false,
                        'searchable' => false,
                        'printable' => false,
                        'exportable' => false,
                            'class'=>'msg',
                    ]
                ]
    

    【讨论】:

      猜你喜欢
      • 2016-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-26
      • 1970-01-01
      • 2013-04-26
      • 2012-10-01
      • 2016-09-25
      相关资源
      最近更新 更多