Datatable Responsive – Using PHP and Mysql with Ajax

I got huge response from datatable tutorials and some users requested share tutorial about responsive datatable. Responsive means a layout which is fit on on each resolution devices like mobile/tablet and desktop which has different resolution screen.

Google also announced that he will give preference those blog/website on search listing which are mobile friendly.You can also check responsiveness of your website/blog using Mozilla/chrome,in Mozilla you can find tool under tools->web developer->responsive design view.

We need two below files to make datatable responsive:

  1. dataTables.responsive.css
  2. dataTables.responsive.js

If you do not know how to use datatable, please read below datatable tutorials:

Datatable Responsive with javaScript and CSS

Step 1: Downloaded above responsiveness file and included into head section of file.

<link rel="stylesheet" type="text/css" href="css/dataTables.responsive.css">
<script type="text/javascript" language="javascript" src="js/dataTables.responsive.min.js"></script>

Step 2: Enable responsive property in your existing datatable using 'responsive: true'.

$('#employee_grid').DataTable({
         "bProcessing": true,
         "serverSide": true,
		 responsive: true,
         "ajax":{
            url :"response.php", // json datasource
            type: "post",  // type of method  , by default would be get
            error: function(){  // error handling code
              $("#employee_grid_processing").css("display","none");
            }
          }
        });  

The PHP and mysql code are same as previous post,You can download source code and see demo from below link.If you have any queries please share using comment section.

You can download source code and Demo from below link.

13 thoughts on “Datatable Responsive – Using PHP and Mysql with Ajax

  1. Great datatable tuts, could you show a example with the export buttons? https://editor.datatables.net/examples/advanced/exportButtons.html

  2. Hi,
    Could someone please help me.
    I would like to add the modal function “edit” and “cancel” to this script for each savings.
    Unfortunately, I can’t find an adequate solution
    Did someone already add this function et could communicate it to me.
    Thank you.

Leave a Reply

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