Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am creating a plunker for another question but I cannot get angular-datatables to sort without configuration.

I have code from a project that responds to sorting when users click on header columns but it just does not want to sort in plunkr.

Am I missing any sort of configuration or overlooking anything?

How do I make the table sortable using default settings?

Plunkr

https://plnkr.co/edit/71RqBQ0HF7ThDyZPpc1E?p=info

HTML

<!DOCTYPE html>
<html>

<head>
  <link data-require="[email protected]" data-semver="1.9.4" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/datatables/1.9.4/css/jquery.dataTables.css" />
<script data-require="[email protected]" data-semver="1.10.1" src="//code.jquery.com/jquery-1.10.1.min.js"></script>
  <script data-require="[email protected]" data-semver="1.9.4" src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.9.4/jquery.dataTables.js"></script>
  <script type="text/javascript" data-require="[email protected]" data-semver="1.2.15" src="//code.angularjs.org/1.2.15/angular.js"></script>
  <script type="text/javascript" src="//rawgithub.com/l-lin/angular-datatables/dev/dist/angular-datatables.min.js"></script>
  <script src="script.js"></script>
</head>

<body ng-app="datatablesSampleApp">
  <div ng-controller="simpleCtrl">
  <div class="table-responsive">
      <table  datatable="ng" class="table" >
              <thead style="background-color: #d8d8d8;">
               <tr>
                   <th>Product</th>
                   <th>Tag Name</th>
                   <th>Unit Size</th>
                   <th>Unit Cost</th>
               </tr>
              </thead>
           <tbody>
                    <tr style="font-weight: 100;" ng-repeat="data in items | filter:{ TagName: filterTag, TagId: filterId} | filter:searchText" >
                    <td class="td-line-height" style="font-weight: 600;';">{{data.Product}}</td>
                    <td class="td-line-height">{{data.TagName}} </td>
                    <td class="td-line-height">{{data.UnitSize}} </td>
                    <td class="td-line-height">{{data.UnitCost | currency}} </td>
                  </tr>
           </tbody>
       </table>
       </div>
  </div>
</body>

</html>
share|improve this question
up vote 1 down vote accepted

for some reason angular-datatables.js is calling isDataTable function while jquery.dataTables.js defines this function as fnIsDataTable, so, to solve it, just add

$.fn.dataTable.isDataTable = $.fn.dataTable.fnIsDataTable;

as your first line in your controller.

here is the error message:

VM892 angular.js:9563TypeError: $.fn.dataTable.isDataTable is not a function
  at Object.renderDataTable (VM1134 angular-datatables.js:753)
  at Object.hideLoadingAndRenderDataTable (VM1134 angular-datatables.js:773)
  at VM1134 angular-datatables.js:910
  at VM892 angular.js:13777
  at completeOutstandingRequest (VM892 angular.js:4236)
  at VM892 angular.js:4537

updated plunker: https://plnkr.co/edit/TgpWLuiTDbb91yJeHYoX?p=preview

share|improve this answer
    
Chrome developer tool or FireFox firebug, under console section, then I checked cdnjs.cloudflare.com/ajax/libs/datatables/1.9.4/… and rawgit.com/l-lin/angular-datatables/dev/dist/… files – Andriy yesterday
    
I removed my original comment on how you found the error, but thanks for the helpful response! – Vahe yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.