2015-07-21 66 views
1

我用angular datatables with fixed column,用於查看下面的我的HTML代碼:角數據表固定列不確定是不是一個函數

<div class="row" ng-controller="PerformanceCtrl"> 
    <table id="example" datatable="" 
      class="stripe row-border order-column" 
      dt-options="dtOptions"> 
     <thead> 
      <tr> 
       <th>First name</th> 
       <th>Last name</th> 

      </tr> 
     </thead> 
     <tbody> 
     <tr> 
      <td>Tiger</td> 
      <td>Nixon</td> 
     </tr> 
    </tbody> 
</table> 

我的控制器代碼如下所示:

'use strict'; 

app.controller('PerformanceCtrl', ['$scope', 'DTOptionsBuilder', 'DTColumnDefBuilder', function ($scope, DTOptionsBuilder, DTColumnDefBuilder) { 

$scope.dtOptions = DTOptionsBuilder.newOptions() 
    .withOption('scrollY', '300px') 
    .withOption('scrollX', '100%') 
    .withOption('scrollCollapse', true) 
    .withOption('paging', false) 
    .withFixedColumns({ 
     leftColumns: 1 
    }); 

}]); 

而對於我index.html文件,我按照以下順序包括數據表庫:

<script src="bower_components/jquery/dist/jquery.min.js"></script> 
<script src="bower_components/angular/angular.js"></script> 
<script src="modules/performance/controller.js"></script> 
<link rel="stylesheet" href="bower_components/angular-datatables/dist/plugins/bootstrap/datatables.bootstrap.css"> 
<script src="bower_components/DataTables/media/js/jquery.dataTables.js"></script> 
<script src="bower_components/angular-datatables/dist/angular-datatables.min.js"></script> 
<script src="bower_components/angular-datatables/dist/plugins/fixedheader/angular-datatables.fixedheader.min.js"></script> 
<script src="bower_components/angular-datatables/dist/plugins/fixedcolumns/angular-datatables.fixedcolumns.min.js"></script> 

<link rel="stylesheet" type="text/css" href="bower_components/DataTables/media/css/jquery.dataTables.min.css"> 

而且這是我的模塊:

var app = angular.module('MyApp', ['datatables', 'datatables.fixedcolumns']); 

但我得到這個錯誤undefined is not a function爲這一形象:

Undefined is not a function

如果我從表中,沒有錯誤的選項去掉下面的代碼,但沒有fixedColumns:

.withFixedColumns({ 
     leftColumns: 1 
    }); 

我需要修正我的第一列,我該如何解決這個錯誤?

+0

請檢查此; ine'angular.module('showcase.withFixedColumns',['datatables','datatables.fixedcolumns'])''。你有注入這個'datatables.fixedcolumns''嗎? –

+0

@RameshRajendran是的,我注入了它,我在問題 –

+0

中添加我的模塊我想我已經通過我的答案來處理您的問題。請讓我知道,如果你有疑問 –

回答

2

我張貼在github這個問題,並在其上1-霖的答案。

我錯過了包括下列內容:

<script src="vendor/FixedColumns-3.0.4/js/dataTables.fixedColumns.min.js"></script> 
<link rel="stylesheet" type="text/css" href="vendor/FixedColumns-3.0.4/css/dataTables.fixedColumns.min.css"> 

我應該下載FixColumns jQuery的。

1

您只是忘了將ng屬性添加到數據表中。

下面正在截屏...

enter image description here

點擊here for Live Demo

+0

演示鏈接不與我合作,並且我添加了'ng'屬性,並且'ng-repeat'與示例數組一起得到了同樣的錯誤 –

相關問題