dimanche 24 décembre 2017

laravel return datatable rows if checkbox is checked

How can I display data if checkbox checked, as example if checkbox which has value (CHECK) is checked then display only rows where the column details has the title CHECK also if checkbox of CREDIT checked then return data of rows where the details cloumn has the two value CHECK and credit. Hope there is away to make this using ajax blade:

   </div><label>CHECK</label> 
   <input type="checkbox" id="chk-20" >
   </div><label>CREDIT</label> 
    <input type="checkbox" id="chk-21" >

     <script type="text/javascript">
     $(function() {
    $('#users-table').DataTable({
    processing: true,
    serverSide: true,
          ajax: 'get_datatable',
    columns : [
          {data: 'details', name: 'details'},
          {data: 'postingdate', name: 'postingdate'},
          {data: 'description', name: 'description'},
           {data: 'amount', name: 'amount'},
          {data: 'type', name: 'type'},
          {data: 'slip', name: 'slip'},
           {data: 'vendor_id', name: 'vendor_id'},
          {data: 'category_id', name: 'category_id'},
        ],
        pageLength: 10,
      });
       });
    </script>

controller

  public function get_datatable()
{ 
 $users=Checks::select(['details','postingdate','description','amount','type','slip','vendor_id','category_id']);
return Datatables::of($users)->editColumn('postingdate', function ($user) 
{

return date('Y/d/m', strtotime($user->postingdate) );
})->make(true);

}




Aucun commentaire:

Enregistrer un commentaire