Laravel Datatables Individual column searching using Ajax Jquery

Laravel Redirect To Another URL / Web Page - HTTP Laravel Redirects

Today, We want to share with you Laravel Datatables Individual column searching using Ajax Jquery.In this post we will show you jquery datatable dropdown column using Laravel example, hear for jquery datatable column filter – server side Laravel example we will give you demo and example for implement.In this post, we will learn about PHP Laravel DataTables example – Individual column searching (select inputs) with an example.

Laravel Datatables Individual column searching using Ajax Jquery

There are the Following The simple About Laravel Datatables Individual column searching using Ajax Jquery Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel datatables individual column filtering example, so the Laravel datatables filter dropdown list for this example is following below.

Laravel EloquentController

public function getMultiFilterSelect()
{
    return view('datatables.eloquent.laravel-filter-data');
    //    return $dataTable->render('path.to.table.view');
}

public function getMultiFilterSelectData()
{
    $members = Member::select(['id', 'name', 'email', 'created_at', 'updated_at']);

    return Datatables::of($members)->make(true);
}

Javascript Part

$('#members-table').DataTable({
    processing: true,
    serverSide: true,
    ajax: 'https://datatables.yajrabox.com/eloquent/laravel-filter-data-data',
    columns: [
        {data: 'id', name: 'id'},
        {data: 'name', name: 'name'},
        {data: 'email', name: 'email'},
        {data: 'created_at', name: 'created_at'},
        {data: 'updated_at', name: 'updated_at'}
    ],
    initComplete: function () {
        this.api().columns().every(function () {
            var column = this;
            var input = document.createElement("input");
            $(input).appendTo($(column.footer()).empty())
            .on('change', function () {
                column.search($(this).val(), false, false, true).draw();
            });
        });
    }
});

Example View:

@extends('app')

@section('content')
{!! $dataTable->table() !!}
@endsection

@push('scripts')
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.0.3/css/buttons.dataTables.min.css">
<script src="https://cdn.datatables.net/buttons/1.0.3/js/dataTables.buttons.min.js"></script>
<script src="/vendor/datatables/buttons.server-side.js"></script>
{!! $dataTable->scripts() !!}
@endpush

Laravel Filter Column

use DataTables;
use DB;

Route::get('member-data', function() {
    $model = App\Member::select([
            'id',
            DB::raw("CONCAT(members.mfname,'-',members.mlaname) as fullname"),
            'email',
            'created_at',
            'updated_at',
        ]);

    return DataTables::eloquent($model)
                ->filterColumn('fullname', function($query, $keyword) {
                    $sql = "CONCAT(members.mfname,'-',members.mlaname)  like ?";
                    $query->whereRaw($sql, ["%{$keyword}%"]);
                })
                ->toJson();
});

Angular 6 CRUD Operations Application Tutorials

Read :

Read Also:  How to declare a global variable in Laravel 5.8?

Summary

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

I hope you get an idea about Laravel Datatables Individual column searching using Ajax Jquery.
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.

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *