How to implement DataTables server-side in laravel

Avinash Nethala
Jul 24, 2017 · 3 min read

Hello every one, welcome back ! This post is an extension to a previous post on DataTables, where we initiated data tables with basic initialization. As many readers suggested to make a tutorial on DataTables server-side am doing this and i strongly recommend you to go through the previous post before proceeding as i do not explain in detail about integrating DataTables , i ‘ll just extend previous post with server-side example.

Datatables server-side implementation in laravel — justlaravel.com

Previous post : How to implement datatables in laravel

For using DataTables server-side operations we use yajra datatables plugin. The plugin can be found at github.com/yajra/laravel-datatables.

Initializing Yajra laravel-datatables plugin

We need to install yajra package using composer.

Run the following the command to install it,

composer require yajra/laravel-datatables-oracle:~6.0

or else add the following code to composer.json file and run composer install

and add DataTables to providers list /config/app.php

],

and finally we publish the configuration,

View part ( showing the table )

Here we show all the data in a table, we use the same data from previous example,

the class names used above for table are as suggested by datatables.net/examples/styling/material.html

DataTables js part

We use some java script to initialize DataTables, process server-side requests and for the material design part we use.

Function to retrieve data from database

As we see in the above script, the ajax call routes to serverSide, here is the logic for it,

We used the same model function from previous tutorial, please look there.

Datatables server-side implementation in laravel - justlaravel.com
Datatables server-side implementation in laravel - justlaravel.com
Datatables server-side implementation in laravel — justlaravel.com

justlaravel

justlaravel.com is website all about laravel where one can find useful tutorials with working demo, source code, video demonstration and more.

Avinash Nethala

Written by

An enthusiast Web Developer and Owner of justlaravel.com, programminginpython.com, mycodingcorner.com and other sites.

justlaravel

justlaravel.com is website all about laravel where one can find useful tutorials with working demo, source code, video demonstration and more.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade