Laravel Server Side Individual Column Filtering

Today, We want to share with you Laravel Server Side Individual Column Filtering.In this post we will show you Server Side Column Filtering with Drop Down, hear for Add Server-side DataTables Custom Filter using Laravel with Ajax we will give you demo and example for implement.In this post, we will learn about Column Search in DataTables using Server-side Processing with an example.

Laravel Server Side Individual Column Filtering

There are the Following The simple About Laravel Server Side Individual Column Filtering Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel Pass Values from Dropdown box using Ajax to Datatable, so the Laravel Filtering Datatables through a dropdown list for this example is following below.

custom dropdown server-side filter

<h3>Add Server-side DataTables Custom Filter using Laravel with Ajax</h3>

  All Status
  Pending
  Open
  Closed
  Normal
  High


<table class="table" id="dtListComments">
  <thead>
    <tr>
      <th>ID</th>
      <th>Name</th>
      <th>Email</th>
      <th>Phone</th>
      <th>Status</th>
    </tr>
  </thead>
  <tbody>
    <!-- Ajax Load -->
  </tbody>
</table>

<a href="https://www.pakainfo.com/" target="_blank" title="pakainfo">Free Download Example - Pakainfo.com</a>



var dtListComments = $("#dtListComments").DataTable({
  "processing": true,
  "serverSide": true,
  "ajax": Laravel.appURL+'/Comments/json',
  "columns": [
    {data: 'id'},
    {data: 'name'},
    {data: 'email'},
    {data: 'phone'},
    {data: 'category'},
  ]
});

$('#categoryFilter').on('change', function(){
  var filter_value = $(this).val();
  var new_url = Laravel.appURL+'/Comment/json/'+filter_value;
  dtListComments.ajax.url('+new_url+').load();
});

Register routes

// Route for list of Comments in json format
Route::get('/Comment/json', '[email protected]')->middleware('ajax');

// Route for list of Comments with specific category in json format
Route::get('/Comment/json/{category}', '[email protected]')->middleware('ajax');

Handle ajax request in the controller

public function json(Request $request)
{
  if($request->category) {
    $Comments = Comment::where('category',$request->category)->get();
    return response()->json(['data' => $Comments]);
  } else {
    $Comments = Comment::get();
    return response()->json(['data' => $Comments]);
  }
}

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel Server Side Individual Column Filtering.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Laravel resource route multiple parameters Example
  2.   PHP Add Days Hours Minutes and Seconds to Datetime
  3.   PHP Array to JSON Array using laravel blade with @json
  4.   How to Disable(false) sorting of one column from DataTables?
  5.   MySQL Full Text Search Laravel Tutorial With Example
  6.   C# Dynamic Data Type Tutorial with Examples
  7.   Vue js Toggle switch Update DB field using Ajax
  8.   Hide Uncategorized category from WooCommerce
  9.   Connecting to MySQL from the command line steps
  10.   jQuery Get Selected Option From Dropdown Example