Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit 89ea95c

Browse files
committed
Add DTColumnDefBuilder
1 parent 26ad65d commit 89ea95c

File tree

135 files changed

+35790
-1308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+35790
-1308
lines changed

demo/angularWayWithOptions.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
*/
55
(function() {
66
'use strict';
7-
angular.module('datatablesSampleApp').controller('angularWayWithOptionsCtrl', function ($scope, $resource, DTOptionsBuilder) {
7+
angular.module('datatablesSampleApp').controller('angularWayWithOptionsCtrl', function ($scope, $resource, DTOptionsBuilder, DTColumnDefBuilder) {
88
$scope.persons = $resource('data.json').query();
99
$scope.dtOptions = DTOptionsBuilder.newOptions().withPaginationType('full_numbers').withDisplayLength(2);
10+
$scope.dtColumnDefs = [
11+
DTColumnDefBuilder.newColumnDef(0),
12+
DTColumnDefBuilder.newColumnDef(1).notVisible(),
13+
DTColumnDefBuilder.newColumnDef(2).notSortable()
14+
];
1015
});
1116
})();

demo/partials/angular_way_with_options.html

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,40 @@ <h1><i class="fa fa-play"></i>&nbsp;The Angular way with options</h1>
77
You can also provide datatable options and datatable column options with the directive
88
<code>dt-options</code>:
99
</p>
10+
<p>
11+
<strong>Note:</strong>
12+
</p>
13+
<ul>
14+
<li>
15+
The options do not override what you define in your template. It will just append its properties.
16+
</li>
17+
<li>
18+
If you use the Angular way of rendering the table along with the Ajax or the promise solution, the latter
19+
will be display.
20+
</li>
21+
<li>
22+
The Angular way is less efficient than fetching the data with the Ajax/promise solutions. The lack of
23+
performance is due to the fact that Angular add the 2 way databinding to the data, which the ajax/promise solutions
24+
does not. However, you can use Angular directive (<code>ng-click</code>, <code>ng-controller</code>...) in there!
25+
</li>
26+
<li>
27+
Don't forget to set the properties <code>ng</code> in the directive <code>datatable</code> and the <code>dt-rows</code>
28+
in order to tell the directive to use the Angular way!
29+
</li>
30+
<li class="text-danger">
31+
<i class="fa fa-warning"></i>&nbsp;When using the angular way, you CANNOT use the <code>dt-column</code> directive. Indeed,
32+
the module will render the datatable after the promise is resolved. So for DataTables, it's like rendering a static table.
33+
If you need to provide some options to your columnn, your must provide the <code>dt-column-defs</code> directive (which corresponds
34+
to the <a href="https://datatables.net/reference/option/columnDefs">DataTables columnDefs</a>).
35+
</li>
36+
</ul>
1037
</section>
1138
<section class="showcase">
1239
<tabset>
1340
<tab heading="Preview">
1441
<article class="preview">
1542
<div ng-controller="angularWayWithOptionsCtrl">
16-
<table datatable="ng" dt-options="dtOptions" dt-columns="dtColumns" class="row-border hover">
43+
<table datatable="ng" dt-options="dtOptions" dt-column-defs="dtColumnDefs" class="row-border hover">
1744
<thead>
1845
<tr>
1946
<th>ID</th>
@@ -35,7 +62,7 @@ <h1><i class="fa fa-play"></i>&nbsp;The Angular way with options</h1>
3562
<tab heading="HTML">
3663
<div hljs>
3764
<div ng-controller="angularWayWithOptionsCtrl">
38-
<table datatable="ng" dt-options="dtOptions" dt-columns="dtColumns" class="row-border hover">
65+
<table datatable="ng" dt-options="dtOptions" dt-column-defs="dtColumnDefs" class="row-border hover">
3966
<thead>
4067
<tr>
4168
<th>ID</th>
@@ -57,36 +84,17 @@ <h1><i class="fa fa-play"></i>&nbsp;The Angular way with options</h1>
5784
<tab heading="JS">
5885
<div hljs language="js">
5986
angular.module('datatablesSampleApp', ['ngResource', 'datatables'])
60-
.controller('angularWayWithOptionsCtrl', function ($scope, $resource, DTOptionsBuilder) {
87+
.controller('angularWayWithOptionsCtrl', function ($scope, $resource, DTOptionsBuilder, DTColumnDefBuilder) {
6188
$scope.persons = $resource('data.json').query();
6289
$scope.dtOptions = DTOptionsBuilder.newOptions().withPaginationType('full_numbers').withDisplayLength(2);
90+
$scope.dtColumnDefs = [
91+
DTColumnDefBuilder.newColumnDef(0),
92+
DTColumnDefBuilder.newColumnDef(1).notVisible(),
93+
DTColumnDefBuilder.newColumnDef(2).notSortable()
94+
];
6395
});
6496
</div>
6597
</tab>
6698
</tabset>
6799
</section>
68-
69-
<section class="article-content">
70-
<p>
71-
<strong>Note:</strong>
72-
</p>
73-
<ul>
74-
<li>
75-
The options do not override what you define in your template. It will just append its properties.
76-
</li>
77-
<li>
78-
If you use the Angular way of rendering the table along with the Ajax or the promise solution, the latter
79-
will be display.
80-
</li>
81-
<li>
82-
The Angular way is less efficient than fetching the data with the Ajax/promise solutions. The lack of
83-
performance is due to the fact that Angular add the 2 way databinding to the data, which the ajax/promise solutions
84-
does not. However, you can use Angular directive (<code>ng-click</code>, <code>ng-controller</code>...) in there!
85-
</li>
86-
<li>
87-
Don't forget to set the properties <code>ng</code> in the directive <code>datatable</code> in order to tell the directive to use
88-
the Angular way!
89-
</li>
90-
</ul>
91-
</section>
92100
</article>

0 commit comments

Comments
 (0)