【问题标题】:Switch Custom in data tables在数据表中切换自定义
【发布时间】:2021-08-21 22:56:51
【问题描述】:

我正在尝试将开关自定义添加到我的数据表中,

所以我正在使用这个函数,它将一个列 Action 添加到 Datatables

function getdata(Request $request)
    {
        if(request()->ajax())
        {
            return datatables()->of(Casting::latest()->get())
                    ->addColumn('action', function($data){
                        $button = '<button type="button"     name="edit" id="'.$data->id.'" class="edit btn btn-primary btn-sm">Modifier</button>';
                        $button .= '&nbsp;&nbsp;';
                        $button .= '<div class="custom-switch custom-switch-secondary-inverse mb-2 custom-switch-small">
                         <input class="custom-switch-input" id="switchS4" type="checkbox">
                                                <label class="custom-switch-btn" for="switchS4"></label></div>';
                        return $button;
                    })
                    ->rawColumns(['action'])
                    ->make(true);
        }
       return view('Casting.castingss');

    }

我得到了这个结果,

如何在编辑按钮的同一行中自定义开关?

【问题讨论】:

  • 在元素上使用 CSS。确切需要哪些属性取决于您的 HTML/CSS,但我建议从 display: inline-block; 开始
  • 我应该在 div 标签内使用 CSS 吗?

标签: html jquery ajax laravel


【解决方案1】:

我确实把我的按钮放在一张桌子上。

$button = '<table border=2><tr><td>';
$button .= 'you 1rts button';
$button .= '</td><td>';
...
$button .= '</td></tr></table>';

【讨论】:

  • 这可能不是最好的答案,但它是目前唯一的一个并且它有效。投反对票的人可以解释原因(并给出更好的答案)还是他或她更喜欢匿名?
  • 对我来说也是,我们应该能够用 css 做一个“更好”的方式,但是......我们还有很多其他事情要做:-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-08-23
  • 1970-01-01
  • 2010-12-04
  • 2014-06-03
  • 2017-07-24
  • 2017-12-31
  • 1970-01-01
相关资源
最近更新 更多