Click here to Skip to main content
15,313,044 members
Articles / Web Development / HTML
Posted 26 Sep 2014


37 bookmarked

Bootstrap Table With Sorting, Searching and Paging using dataTable.js (Responsive)

Rate me:
Please Sign up or sign in to vote.
4.86/5 (32 votes)
26 Sep 2014CPOL1 min read
This tip presents an example of datatable in responsive using bootstrap and dataTable.js


This tip presents an example of DataTable in Responsive using bootstrap. The DataTable.js automatically provides column sorting, searching and paging. DataTable.js is just like a .js file. It's open source. In many of the applications, we need to display data as a table format so in this scenario, if we will use this library then it reduces our work and it increases the efficiency.



DataTable.js is just like a JavaScript library we can use in any web related projects. It automatically provides column sorting, searching and paging functionalities.


Bootstrap is the most popular for HTML, CSS and JS framework for developing responsive applications.


Responsive means the single application will target any device like mobile, tablet, small PC and large PC.

Using the Code

Here is the code to display dataTable in responsive mode.

The JQuery is the top of all the .js libraries.

First, we need to include the required libraries.

// These are required files we must include these libraries 

<link href="" rel="stylesheet">   
<script src=""></script>
<link rel="stylesheet" 
<script type="text/javascript" 
<script type="text/javascript" 

After including all required libraries, put your HTML table either static or dynamic.

Here I am showing static HTML table. If your table is dynamic, it is also the same.

// Table with data
<table id="myTable">  
            <td>United Kingdom</td>  

Finally, after creating table, we need to add some jquery code for dataTable functionalites to our table id.

// This only line code describes to bind datatable functionalities like searching, sorting and paging to our table.
// Here 'myTable' is the ID of our table

Now our dataTable is ready with sorting, searching and paging.

Now we need to make the table as responsive. For that, we need to include bootstrap CSS class 'table table-striped'.

<table id="myTable" class="table table-striped" >  

or we have another method to do the same thing in responsive:

<div class="table-responsive">
<table id="myTable" class="display table" width="100%" >

//The table data come here...


That's it! The output looks like this in PC.

Image 1

The output in Smart phone is like this:

sampleoutput in mobile

Points of Interest

I love this very much. It's much simpler and it saves more time.


  • 26-09-2014


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Comments and Discussions

QuestionEdit gridview by keeping the pagination Pin
Member 1011261112-Aug-19 23:50
MemberMember 1011261112-Aug-19 23:50 
QuestionRegarding different behavior of chrome w.r.t script Pin
Member 1401967714-Oct-18 22:31
MemberMember 1401967714-Oct-18 22:31 
Bugpagination not working how can i solve it Pin
Member 1353719423-Nov-17 1:16
MemberMember 1353719423-Nov-17 1:16 
QuestionNot working Pin
Member 1353719423-Nov-17 0:08
MemberMember 1353719423-Nov-17 0:08 
PraiseArticle Pin
Gautam Chaudhari26-Sep-17 20:02
MemberGautam Chaudhari26-Sep-17 20:02 
QuestionSQL data binding to grid Pin
Member 80776445-Aug-17 21:02
MemberMember 80776445-Aug-17 21:02 
QuestionBootstrap Table With Sorting, Searching and Paging Pin
Darrell Ulm20-Jun-17 9:37
MemberDarrell Ulm20-Jun-17 9:37 
AnswerRe: Bootstrap Table With Sorting, Searching and Paging Pin
Member 1176957813-Mar-18 6:22
MemberMember 1176957813-Mar-18 6:22 
QuestionBootstrap Table With Sorting, Searching and Paging using dataTable.js Pin
Member 1304128326-Mar-17 11:59
MemberMember 1304128326-Mar-17 11:59 
QuestionNot working in Chrome - Bootstrap Table With Sorting, Searching and Paging using dataTable.js (Responsive) Pin
Member 1173388422-Feb-17 3:13
MemberMember 1173388422-Feb-17 3:13 
AnswerRe: Not working in Chrome - Bootstrap Table With Sorting, Searching and Paging using dataTable.js (Responsive) Pin
Member 1304128326-Mar-17 12:01
MemberMember 1304128326-Mar-17 12:01 
Questiondisabling sorting for one column Pin
Member 97662734-Oct-16 21:06
MemberMember 97662734-Oct-16 21:06 
Questionrelated to table data Pin
Member 1274267115-Sep-16 16:49
MemberMember 1274267115-Sep-16 16:49 
GeneralMy vote of 5 Pin
srfox22-Aug-16 17:17
professionalsrfox22-Aug-16 17:17 
QuestionDynamic Data will not refresh Pin
Member 1249152728-Apr-16 8:57
MemberMember 1249152728-Apr-16 8:57 
QuestionTable With Sorting, Searching and Paging Pin
renjithstephen10-Mar-16 23:06
Memberrenjithstephen10-Mar-16 23:06 
QuestionHTML Table bind through Json. Pin
Abhisek Munshi16-Dec-15 1:42
MemberAbhisek Munshi16-Dec-15 1:42 
Questionnot working in .cshtml Pin
Baraneedharan(Baranee)15-Dec-15 5:26
MemberBaraneedharan(Baranee)15-Dec-15 5:26 
PraiseGreat article Pin
Rajdeep Debnath15-Dec-15 1:30
MemberRajdeep Debnath15-Dec-15 1:30 
Questionhow to refresh table after updating rows by ajax? Pin
Richard_Michael_RM14-Dec-15 23:14
MemberRichard_Michael_RM14-Dec-15 23:14 
QuestionVerrry Useful Post !! Helped me a lot !! Pin
Member 1215166919-Nov-15 0:40
MemberMember 1215166919-Nov-15 0:40 
QuestionLosing results if dynamically loaded Pin
floydus2714-Nov-15 11:31
Memberfloydus2714-Nov-15 11:31 
QuestionHow to make it work in "Grayscale" bootstrap template? Pin
Jacek Miłaszewski28-Sep-15 0:07
MemberJacek Miłaszewski28-Sep-15 0:07 
QuestionWhere to add? Pin
Member 1179634110-Sep-15 20:48
MemberMember 1179634110-Sep-15 20:48 
Question¿How can I edit the html that appears when I implement the javascript? Pin
Hilary Madrigal Valverde4-Jul-15 13:09
MemberHilary Madrigal Valverde4-Jul-15 13:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.