title: Disable column sorting not working for multiple angularjs datatables
body: <p>I am working with multiple angularjs data tables and generating a new table every time user selects an option from the drop down list.Based on the user's selection i make an $http request to fetch new data from the database .For every table i have different dtColumnDefs which is set dynamically since my table column headers are dynamic except 1st two and last columns.My intention is to disable sorting for these dynamic column headers.I am able to find out total number of dynamic columns then run a loop to dynamically disable sorting on those columns.Though the data table renders successfully for every user input but expected columns sorting options are not getting disabled. 
  Check the <a href="http://plnkr.co/edit/4Js7ZGQAbJMYQVX1NchN?p=preview" rel="nofollow noreferrer">plunker</a> for demo.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>This is a demo table to understand how to proceed but my original table is little bit complex where i am showing some database rows as column headers and there is also some filtering such as unique ,i am also using index value to count the serial so i could not accept <code>davidkonrad</code>'s answer as i don't want to define columns from controller. 
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module('myApp', ['datatables']);
  app.controller('MyCtrl', function($scope, DTOptionsBuilder, DTColumnBuilder, DTColumnDefBuilder) {
  
      $scope.department = [{
              value: "1",
              name: "sales"
          },
          {
              value: "2",
              name: "admin"
          },
          {
              value: "3",
              name: "other"
          }
      ];
  
      $scope.dep = $scope.selected_dep;
      $scope.i = 0;
      $scope.depshow = function() {
          $scope.i += 1;
          var x = 'v' + $scope.i;
          $scope.m = 'v' + $scope.i;
          $scope.dep = $scope.selected_dep;
          if ($scope.dep == 1) {
              $scope.list = [{
                      "eid": "10",
                      "dyn1": "dval1",
                      "dyn2": "dval2",
                      "dyn3": "dval3",
                      "sales": "20"
                  },
  
                  {
                      "eid": "20",
                      "dyn1": "dval1",
                      "dyn2": "dval2",
                      "dyn3": "dval3",
                      "sales": "20"
                  },
                  {
                      "eid": "30",
                      "dyn1": "dval1",
                      "dyn2": "dval2",
                      "dyn3": "dval3",
                      "sales": "20"
                  }
              ];
          } else if ($scope.dep == 2) {
              $scope.list = [{
                      "eid": "40",
                      "dyn1": "dval1",
                      "dyn2": "dval2",
                      "dyn3": "dval3",
                      "sales": "20"
                  },
  
                  {
                      "eid": "50",
                      "dyn1": "dval1",
                      "dyn2": "dval2",
                      "dyn3": "dval3",
                      "sales": "20"
                  },
                  {
                      "eid": "60",
                      "dyn1": "dval1",
                      "dyn2": "dval2",
                      "dyn3": "dval3",
                      "sales": "20"
                  }
              ];
          }
          if ($scope.dep == 3) {
              $scope.list = [{
                      "eid": "70",
                      "dyn1": "dval1",
                      "dyn2": "dval2",
                      "dyn3": "dval3",
                      "sales": "20"
                  },
  
                  {
                      "eid": "80",
                      "dyn1": "dval1",
                      "dyn2": "dval2",
                      "dyn3": "dval3",
                      "sales": "20"
                  },
                  {
                      "eid": "0",
                      "dyn1": "dval1",
                      "dyn2": "dval2",
                      "dyn3": "dval3",
                      "sales": "20"
                  }
              ];
          }
  
          $scope.x = {};
  
          $scope.x.dtOptions = DTOptionsBuilder.newOptions()
              .withOption('order', [0, 'asc']);
  
          $scope.ln = 4;
          $scope.x.dtColumnDefs = [];
          for (var i = 1; i &lt; $scope.ln; i++) {
  
              $scope.x.dtColumnDefs.push(DTColumnDefBuilder.newColumnDef(i).notSortable());
          }
      }
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    &lt;html&gt;
              &lt;head&gt;
                &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt;
                &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"&gt;&lt;/script&gt;
                &lt;script src="http://phpflow.com/demo/angular_datatable_demo/angular-datatables.min.js"&gt;&lt;/script&gt;
                &lt;script src="http://phpflow.com/demo/angular_datatable_demo/jquery.dataTables.min.js"&gt;&lt;/script&gt;
                &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"&gt;
                &lt;link rel="stylesheet" href="http://phpflow.com/demo/angular_datatable_demo/datatables.bootstrap.css"&gt; 
              &lt;/head&gt;
              &lt;div class="container"&gt;
              &lt;div ng-app="myApp" ng-controller="MyCtrl"&gt;
      Select    &lt;select ng-model="selected_dep" ng-change="depshow()" ng-options="item.value as item.name for item in department"&gt;
  
      &lt;option value=""&gt;select a department&lt;/option&gt;   
       &lt;/select&gt;
          
              &lt;table  class="table table-striped table-bordered" datatable="ng" dt-options="m.dtOptions" dt-column-defs="m.dtColumnDefs" &gt;
                  &lt;thead&gt;
                    &lt;tr&gt;
                 &lt;th&gt;sr&lt;/th&gt;
  
                 &lt;th&gt;Employee ID&lt;/th&gt;
                 &lt;th&gt;dynamic clm1&lt;/th&gt;
                    &lt;th&gt;dynamic clm2&lt;/th&gt;
                 &lt;th&gt;dynamic clm3&lt;/th&gt;
                &lt;th&gt;sales&lt;/th&gt;
  
              &lt;/thead&gt;
                  &lt;tbody&gt;
                
                 &lt;tr ng-repeat="data in list"&gt;
                     &lt;td&gt; {{$index+1}} &lt;/td&gt;
                                       
                    &lt;td&gt; {{ data.eid }} &lt;/td&gt;
                    &lt;td&gt; {{ data.dyn1 }} &lt;/td&gt;
                    &lt;td&gt; {{ data.dyn2 }} &lt;/td&gt;
                    &lt;td&gt; {{ data.dyn3 }} &lt;/td&gt;
                    
                    &lt;td&gt; {{ data.sales }} &lt;/td&gt;
                    &lt;/tr&gt;
              &lt;/tbody&gt;
              &lt;/table&gt;
              &lt;/div&gt;
   &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>