melissa maya
melissa maya

Reputation: 119

Switch Custom in data tables

I'm trying to add a switch custom to my Datatables,

So I'm using this function which adds a column Action to 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');

    }

I get that result , enter image description here

How can I get the switch custom in the same row of the Edit Button?

Upvotes: 0

Views: 220

Answers (1)

Dri372
Dri372

Reputation: 1321

I do put my buttons in a table.

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

Upvotes: 2

Related Questions