Datatable
Datatable copied to clipboard
Sort or Order by checked checkbox column
Hi, Is there a way to Sort or Order de results by first getting the Checked elements in a checkbox?? I added the column field in
->orderColumns('column_with_the_checkboxes')
But it ordered in a strange way. I want to be able to to this http://datatables.net/examples/plug-ins/dom_sort.html
Here is my code
return Datatable::collection(Product::all())
->searchColumns('nombre', 'seccion', 'subseccion')
->addColumn('selecciona', function($model) use ($id){
$related = Product::find($id);
$related = $related->infoProduct->productos_relacionados;
$array = explode(",", $related);
if (in_array($model->id, $array)) {
return '<input type="checkbox" name="choose" value="'.$model->id.'" checked="checked">';
} else {
return '<input type="checkbox" name="choose" value="'.$model->id.'">';
}
})
->showColumns('id', 'nombre', 'seccion', 'subseccion')
->orderColumns('selecciona', 'nombre', 'seccion', 'subseccion')
->make();