'Laravel 5 Datatable Search not working in all columns of the datatable
I am implementing datatables using three tables in my database. I joined all threeofthem together (employee, person, suffix). Datatable is reflected correctly. Butmy problem is when i search an employee using there first name or employee number,it isworkingfine and displays the employees base on what i search.However when i search using their last name, middle name or suffix, it says nomatching records even if that employee existed.
here is my bladefile
<div id="page-wrapper">
<div class="row">
<div class="page-header"><br>
<h2>Personnel Information List</h2>
<h5>Select Employee Personnel</h5>
</div>
<div class="row">
<div class="col-md-12">
<table id="EmployeeFilter" class="table table-striped table-hover">
<thead>
<tr>
<th> {{ Lang::get("employee.employee_no") }}</th>
<th> {{ Lang::get("employee.employee_name") }}</th>
<th> {{ Lang::get("form.action") }}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
here is my script
<script type="text/javascript">
var oTable;
$(document).ready(function() {
oTable = $('#EmployeeFilter').DataTable( {
"sDom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
"sPaginationType": "bootstrap",
"bProcessing": true,
"bServerSide": true,
"bStateSave": true,
"sAjaxSource": "{{ URL::to('employee_report/data')}}",
"aoColumns": [
null,
null,
null,
],
"fnDrawCallback": function ( oSettings ) {},
});
});
</script>
and here is my controller that returns the data table
public function data() { $personnel_employee_list = Employee::join('person','employee.person_id','=','person.id') ->leftJoin('suffix','person.suffix_id','=','suffix.id') ->select(array('employee.id','employee.employee_no','person.first_name', 'person.middle_name','person.last_name','suffix.suffix_name')) ->orderBy('employee.employee_no', 'ASC');
return Datatables::of($personnel_employee_list)
->add_column('actions', '<a href="{{{ URL::to("employee_report/personal_info_sheet/" .$id) }}}" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-list-alt"></span> View Details</a>
<input type="hidden" name="row" value="{{$id}}" id="row">')
->editColumn('first_name','{{ ucwords(strtolower($first_name." ".$middle_name." ".$last_name." ".$suffix_name)) }}')
->editColumn('first_name','{{ ucwords((str_replace("ñ","ñ",str_replace("Ñ","Ñ",$first_name))." ".str_replace("ñ","ñ",str_replace("Ñ","Ñ",$middle_name))." ".str_replace("ñ","ñ",str_replace("Ñ","Ñ",$last_name)) . " ".str_replace("ñ","ñ",str_replace("Ñ","Ñ",$suffix_name)) )) }}')
->removeColumn('id', 'middle_name', 'last_name', 'suffix_name')
->make();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
