Introduction
In this article, I am going to explain how to use and integrate the jQuery datatable with AngularJS. DataTable is a prebuild functionality and a plug-in for the jQuery JavaScript library. It is a highly flexible tool based upon the foundations of progressive enhancement. It adds advanced interaction controls to any HTML table.
Overview of the process
- Create a web page to display the data.
- Get data from a SharePoint list.
- Reference jQuery datatable in the header of HTML file.
- Integrate the jQuery datatable with AngularJS.
Create a web page with a Table view to display the data which we get from the script code.

HTML
Here is the HTML code for the look and feel of the above webpage. We must need the table view to integrate the jQuery datatable.
- <table width="100%" cellspacing="0" border="1">
- <thead id="TblHead">
- <tr>
- <td>View</td>
- <td>Req No.</td>
- <td>Vendor</td>
- <td>Date Required </td>
- <td>Requisition Date</td>
- <td>Approval Status</td>
- <td>Order Status</td>
- <td>Notify</td>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat="MyOrder in MyOrders">
- <td><a title='Click to view' href="#" target='_blank' class='btn btn-info btn-md'><span class='glyphicon glyphicon-user'></span> View</a></td>
- <td> {{MyOrder.OrderFrom}}</td>
- <td>{{MyOrder.Vendor}}</td>
- <td>{{MyOrder.DateRequired | date}}</td>
- <td>{{MyOrder.RequisitionDate | date}}</td>
- <td>{{MyOrder.WorkStatus}}</td>
- <td>{{MyOrder.OrderStatus}}</td>
- <td>Notify</td>
- </tr>
- </tbody>
- </table>
Where all the <tr> tags will repeat as per the data in the list using the ng-repeat directive of AngularJS.
Step 2
Get all the data from the SharePoint list on page load. This is the script code for retrieving the data from a SharePoint list using Angular with REST call.
- $http({
- method: 'GET',
- url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('RequisitionOrders')/Items",
- headers: {
- "Accept": "application/json;odata=verbose"
- }
- }).success(function(data, status, headers, config) {
- Console.log(data.d.results);
- }).error(function(data, status, headers, config) {});
Integrate the jQuery Datatable with AngularJS as below.
In HTML file
Type the below line in your HTML file. The ID in HTML will help to bind the datatable functionalities to the entire table.
- <table width="100%" cellspacing="0" id="user_table" class="users list dtable" border="1">
Store the retrieved data to a scope.
- $scope.MyOrders = data.d.results;
Then, the defined scope variable named $scope.MyOrders will be used as settings for the data tables.
Integrate the Datatable to the AngularJS by adding the following code in success.
- angular.element(document).ready(function() {
- dTable = $('#user_table')
- dTable.DataTable();
- });
References
Please add the following JS & CSS files to your code in the following order.
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
- <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />
- <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
- <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
- <script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>
- <script src="https://code.angularjs.org/1.3.0/angular.js"></script>
Let’s see the result on screen as below.
Hence, we have integrated the jQuery datatable to an Angular application successfully. Now, all the functionalities will work with the AngularJS application just same as they work in a jQuery application.
Conclusion
In modern web applications, most of us are likely to develop single page applications. To do so, we use AngularJS. Usually, table manipulation in AngularJS is easier than in normal jQuery. But still, search and server-side pagination are not straight forward in AngularJS. Hence, we can use datatable in AngularJS too.

Balasubramanian RamamoorthiPosted Aug 2, 2024, 9:20 AM
This is what exactly i am looking for. I have similar code in my project but some column has dropdown, input boxes. User will select and enter data in the columns and submit. data sh get updated in db. can you help.
legendgod legendgodPosted Sep 13, 2019, 4:47 AM
Can I join 2 lists (with same structure) and show in single datatable?
Jayesh PagarePosted Sep 4, 2019, 1:38 AM
How to reload or refresh datatable with above solution
Eduardo TapiaPosted Jul 23, 2019, 12:15 PM
Im tryed send you a email but it was not delivered because the recipient's email provider rejected it.
Eduardo TapiaPosted Jul 22, 2019, 11:00 PM
Hello bro, I am trying to make an example like yours but it does not work and the loading of the DTable interfaces but the buttons of the page does not work and does not respect the maximum of lines that should show.<script> var app = angular.module('myApp', []); app.controller('myCtrl', function ($scope) { $scope.JInfo = [ { nombre: '1', apellido: 'Doe' }, { nombre: '2', apellido: 'Doe' }, { nombre: '3', apellido: 'Doe' }, { nombre: '4', apellido: 'Doe' }, { nombre: '5', apellido: 'Doe' }, ] angular.element(document).ready(function () { $.extend($.fn.dataTable.defaults, { searching: false, ordering: false }); dTable = $('#user_table') dTable.DataTable(); }); }); </script> </head> <body ng-app="myApp"> <div class="container" ng-controller="myCtrl"> <table class="table" id="user_table" hibb> <thead> <tr> <th>Nombre</th> <th>Apellido</th> </tr> </thead> <tbody ng-repeat="item in JInfo"> <tr> <td>{{item.nombre}}</td> <td>{{item.apellido}}</td> </tr> </tbody> </table> </div> </body>
vijendar kumarPosted May 3, 2019, 1:57 AM
It is not working.i download the zip file but no found ../CSS/YourCSSFile.css.
bainapalli krishnaPosted Nov 22, 2018, 9:38 AM
It is not working
Farhan AhmedPosted Jul 24, 2018, 4:20 AM
Like it.......
Code BckpsPosted May 14, 2018, 12:50 AM
That's simple and easy, Thanks!!
Satheesh MPosted Apr 24, 2018, 1:17 AM
Helo reddy , I am using angularjs to populate the grid with below codefunction getAllContacts() { contactService.getAllContacts().then(function (result) { if (result.data && result.data.contacts && result.data.contacts.length > 0) { $scope.contacts = result.data.contacts; angular.element(document).ready(function () { dTable = $('#tblAllContacts'); dTable.DataTable(); }); } }); } My Html : <table class="table table-striped dataTable no-footer" id="tblAllContacts"> <thead> <tr> <th></th> <th>Name</th> <th>Email ID</th> <th>Phone #</th> <th>Position</th> <th>Rank</th> </tr> </thead> <tbody ng-repeat="contact in contacts"> <tr> <td class="text-center"> <div class="squaredFour"> <input type="checkbox" value="None" id="{{contact.contact_id}}" name="check" /> <label for="{{contact.contact_id}}"></label> </div> </td> <td> <a href="#edit-contact" data-toggle="modal">{{contact.first_name}}</a> </td> <td> <i class="fa fa-facebook-f"></i>{{contact.email}} </td> <td>{{contact.phone}}</td> <td> {{contact.position}}</td> <td> <i class="fa fa-star text-warning"></i> <i class="fa fa-star text-warning"></i> <i class="fa fa-star text-warning"></i> <i class="fa fa-star-half-empty text-warning"></i> </td> <!-- <td><a href="#"><i class="fa fa-edit"></i></a></td> --> </tr> </tbody> </table> My issue is pagination is not working . It says no data available also in below of the grid.Any idea?
prashanth krishPosted Feb 5, 2018, 1:28 AM
Thank u so much Mahipal Reddy
Jerry LiangPosted Jan 18, 2018, 11:58 PM
Thanks you are my hero!
venkatarao BPosted Dec 8, 2017, 1:38 AM
Search is not working
Azarudeen AnifaPosted Nov 23, 2017, 11:57 AM
Angular 1.6.6. I am getting error that "TypeError: Cannot read property 'childNodes' of undefined at compositeLinkFn (angular.js:7518)". How to avoid this
Alagappapandian MPosted Oct 26, 2017, 1:12 AM
Great.!Thanks for Sharing. Is it possible to server side sorting and pagination ?
Mohammed Deeb HammoudehPosted Oct 25, 2017, 3:02 AM
Stunning Article , thanks for your efforts.