Introduction
In this article, we will learn how to make an ASP GridView responsive using jQuery based DataTables plug-in.
Nowadays every website is made responsive. Most of the web developers are familiar with responsive websites but still, there are some beginners who don't know much about responsive websites. So, beginners, in simple terms, a responsive website is one that is compatible with different devices having different screen resolutions, like desktop, laptop, tablet, and mobile etc. The website is adapted to have the best viewing experience in all the above devices without any horizontal scrollings and all. This is achieved mainly with the help of CSS, HTML 5, and jQuery.
One of the major headaches in making a website responsive is to manage the HTML tables. So, here is a plug-in built on jQuery to manage the tables and make them responsive, the DataTables plug-in. So in our article, we are going to make a GridView responsive using DataTables plug-in. Before going to that, let's see how to make a simple HTML table responsive using DataTables plug-in.
Responsive HTML tables using DataTables
Consider an HTML table as shown below that contains Employee details.
In this article, we will learn how to make an ASP GridView responsive using jQuery based DataTables plug-in.
Nowadays every website is made responsive. Most of the web developers are familiar with responsive websites but still, there are some beginners who don't know much about responsive websites. So, beginners, in simple terms, a responsive website is one that is compatible with different devices having different screen resolutions, like desktop, laptop, tablet, and mobile etc. The website is adapted to have the best viewing experience in all the above devices without any horizontal scrollings and all. This is achieved mainly with the help of CSS, HTML 5, and jQuery.
One of the major headaches in making a website responsive is to manage the HTML tables. So, here is a plug-in built on jQuery to manage the tables and make them responsive, the DataTables plug-in. So in our article, we are going to make a GridView responsive using DataTables plug-in. Before going to that, let's see how to make a simple HTML table responsive using DataTables plug-in.
Responsive HTML tables using DataTables
Consider an HTML table as shown below that contains Employee details.
- <table id="mytable" cellpadding="5" border="1" cellspacing="0" width="100%">
- <thead>
- <tr>
- <th>
- Employee Code
- </th>
- <th>
- Employee Name
- </th>
- <th>
- Employee Age
- </th>
- <th>
- Designation
- </th>
- <th>
- Experience
- </th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>
- 10011
- </td>
- <td>
- Rajeev
- </td>
- <td>
- 31
- </td>
- <td>
- Developer
- </td>
- <td>
- 6
- </td>
- </tr>
- <tr>
- <td>
- 10012
- </td>
- <td>
- Sandhya
- </td>
- <td>
- 27
- </td>
- <td>
- Tester
- </td>
- <td>
- 2
- </td>
- </tr>
- <tr>
- <td>
- 10013
- </td>
- <td>
- Ramesh
- </td>
- <td>
- 25
- </td>
- <td>
- Designer
- </td>
- <td>
- 1
- </td>
- </tr>
- <tr>
- <td>
- 10014
- </td>
- <td>
- Sanjay
- </td>
- <td>
- 32
- </td>
- <td>
- Developer
- </td>
- <td>
- 5
- </td>
- </tr>
- <tr>
- <td>
- 10015
- </td>
- <td>
- Ramya
- </td>
- <td>
- 23
- </td>
- <td>
- Developer
- </td>
- <td>
- 1
- </td>
- </tr>
- </tbody>
- </table>
On viewing in browser, it will be like below.

Also, on mobile browser, it will be as below.

We can clearly see that the last columns are hidden in mobile screen. We need to scroll horizontally for viewing those columns. So now, we are going to make this table responsive. For that, first, add references to the plug-in JS and CSS files in the head section of your page.

Also, on mobile browser, it will be as below.

We can clearly see that the last columns are hidden in mobile screen. We need to scroll horizontally for viewing those columns. So now, we are going to make this table responsive. For that, first, add references to the plug-in JS and CSS files in the head section of your page.
- <!DOCTYPE html>
- <html lang="en">
- <head id="Head1" runat="server">
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Responsive Table using Datatable plug-in</title>
- <link href="Files/jquery.dataTables.css" rel="stylesheet" type="text/css" />
- <link href="Files/responsive.bootstrap.min.css" rel="stylesheet" type="text/css" />
- <script src="Files/jquery-1.10.2.min.js" type="text/javascript"></script>
- <script src="Files/jquery.dataTables.js" type="text/javascript"></script>
- <script src="Files/dataTables.responsive.min.js" type="text/javascript"></script>
- </head>







leslie chowPosted Oct 25, 2017, 11:41 AM
It's a fantastic article on this, i have done something like this on a project. Find this on the link - https://youtu.be/rAMykAy3fXM
Siva KumarPosted Aug 26, 2017, 11:17 AM
Nice article with good explanation.
Humayun Kabir MamunPosted Aug 25, 2017, 7:24 PM
Thanks for this helpful step by step tutorial
Rohit PrakashPosted Aug 25, 2017, 5:56 AM
Useful article, Midhun .