I added a toggle switch custom to my datatable , using the following code :
function getdata(Request $request)
{
if(request()->ajax())
{
return datatables()->of(Casting::latest()->get())
->addColumn('action', function($data){
$button = '<table><tr><td>';
$button .= '<button type="button" name="edit" id="'.$data->id.'" class="edit btn btn-primary btn-sm">Modifier</button>';
$button .= '</td><td>';
$button .= ' <div class="custom-control custom-switch">';
$button .= ' <input type="checkbox" class="custom-control-input" id="switch1" name="example"';
if ($data->status == 1) {
$button .= "checked";
}
$button .= '><label class="custom-control-label" for="switch1">Toggle me</label>
</div>';
$button .= '</td></tr></table>';
return $button;
})
->rawColumns(['action'])
->make(true);
}
return view('Casting.castingss');
}
But I get a checkbox instead of a toggle switch custom.
EDIT
Now I get That :
But I can switch just the first row thr other rows stay fixed
hi u should define the div before the switch button like this
the css will be :
and the code will be :
for exemple if u delete all the css i put in here and add let only the first
u will get only checkbox the u can edit it as u like with css :D i hope i helped u Good luck