mardi 26 décembre 2017

Laravel - show data in datatables with checkbox and ajax

I want the data to appear in the datatable when the checkbox is checked, by the value of the checkbox , if the value is credit that shows all rows containing a credit in the column name details and so on

view:

 <input type="checkbox" id="credit" value="credit" >
 <table id="users-table">
 <thead>
<tr>
  <td>Details</td>
  <td>Date</td>
  <td>Description</td>
 </tr>
</thead>
</table>

ajax

  <script type="text/javascript">
    $(function() {
    $('#users-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: 'student/get_datatable',
        columns : [
            {data: 'details'},
            {data: 'Date'},
            {data: 'Description'},
        ],
        pageLength: 5,
    });
    });
  </script>

controller

 public function get_datatable()
  {

    return Datatables::eloquent(Checks::query())->make(true);
  }




Aucun commentaire:

Enregistrer un commentaire