2

I used angular datatables with fixed column, my HTML code for view as the following:

<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>

And my controller code as the following:

'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
    });

}]);

And for my index.html file, I included datatables libraries as the following order:

<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">

And This my module:

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

But I got this error undefined is not a function as this image:

Undefined is not a function

If I removed the following code from options of table, No error but no fixedColumns:

.withFixedColumns({
        leftColumns: 1
    });

I need to make my first column fixed, How can I fix this error ?

3
  • Please check this ;ine angular.module('showcase.withFixedColumns', ['datatables', 'datatables.fixedcolumns']) . have you inject this datatables.fixedcolumns' ? Commented Jul 21, 2015 at 19:33
  • @RameshRajendran Yes, I injected it, I add my module in Question Commented Jul 21, 2015 at 19:39
  • I think i have fount your issue by my answer. please let me know, if you have doubt Commented Jul 21, 2015 at 20:09

2 Answers 2

3

I post this question on github, and l-lin answer on it.

I missed including the following:

<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">

I should download the FixColumns jQuery.

Sign up to request clarification or add additional context in comments.

Comments

1

You just forgot to add the ng attribute to the datatables.

Below is working Screen shot ...

enter image description here

Click here for Live Demo

1 Comment

The demo link not working with me, and I added ng attribute, and ng-repeat with sample array, got the same error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.