Skip to content

Commit b5117ba

Browse files
committed
Example for this pull request: DataTables/DataTablesSrc#152
0 parents  commit b5117ba

File tree

4 files changed

+616
-0
lines changed

4 files changed

+616
-0
lines changed

app.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var app = angular.module('app', ['datatables', 'datatables.buttons', 'datatables.light-columnfilter']);
2+
3+
app.controller('myController', ['$scope', 'DTOptionsBuilder', function($scope, DTOptionsBuilder) {
4+
$scope.rows = [['ASD', 'qwe', '12', '20', '2019-11-11', '123'], ['2ASD', '2qwe', '212', '220', '2019-11-12', '2123']];
5+
$scope.columnfilter_object = {};
6+
for (var i = 0; i < 6; i++) {
7+
$scope.columnfilter_object[String(i)] = {html: 'input', type: 'text'};
8+
}
9+
$scope.dtOptions = DTOptionsBuilder.newOptions()
10+
.withButtons(['colvis'])
11+
.withOption('scrollX', true)
12+
13+
.withLightColumnFilter($scope.columnfilter_object);
14+
}]);

document.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
$( document ).ready(function() {
2+
var myDataTable = $('#myTable').DataTable( {
3+
"scrollX": true,
4+
dom: 'Bfrtip',
5+
"buttons": [
6+
{
7+
"extend": 'colvis',
8+
'text': '<button class="btn btn-default" id="btnColvis" style="margin-right:0px !important;background-color:inherit;">Columns<span class= "fa fa-caret-down" aria-hidden="true" style="margin-bottom:3px;"></span></button>',
9+
"columns": ':not(.noVis)',
10+
},
11+
]
12+
} );
13+
14+
new $.fn.dataTable.ColumnFilter(myDataTable, {
15+
0: {
16+
html: 'input',
17+
type: 'text',
18+
regexp : true
19+
},
20+
1: {
21+
html: 'input',
22+
type: 'text',
23+
regexp : true
24+
},
25+
2: {
26+
html: 'input',
27+
type: 'text',
28+
regexp : true
29+
},
30+
3: {
31+
html: 'input',
32+
type: 'text',
33+
regexp : true
34+
},
35+
4: {
36+
html: 'input',
37+
type: 'text',
38+
regexp : true
39+
},
40+
5: {
41+
html: 'input',
42+
type: 'text',
43+
regexp : true
44+
},
45+
6: {
46+
html: 'input',
47+
type: 'text',
48+
regexp : true
49+
}
50+
});
51+
});

index_angular.html

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<html ng-app="app">
2+
<head>
3+
<script
4+
src="https://code.jquery.com/jquery-3.4.1.min.js"
5+
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
6+
crossorigin="anonymous"></script>
7+
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css"></link>
8+
<script
9+
src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
10+
<script
11+
src="https://cdn.datatables.net/buttons/1.6.0/js/dataTables.buttons.min.js"></script>
12+
<script
13+
src="https://cdn.datatables.net/buttons/1.6.0/js/buttons.colVis.js"></script>
14+
<script
15+
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dataTables.lightColumnFilter.min.js"></script>
16+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.8/angular.js"></script>
17+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-datatables/0.6.2/angular-datatables.min.js"></script>
18+
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-datatables/0.6.2/plugins/buttons/angular-datatables.buttons.min.js"></script>
19+
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-datatables/0.6.2/plugins/light-columnfilter/angular-datatables.light-columnfilter.min.js"></script>
20+
<script src="app.js"></script>
21+
</head>
22+
<body ng-controller="myController">
23+
<table id="myTable" class="display" style="width:100%" datatable="ng" dt-options="dtOptions">
24+
<thead>
25+
<tr>
26+
<th>Name</th>
27+
<th>Position</th>
28+
<th>Office</th>
29+
<th>Age</th>
30+
<th>Start date</th>
31+
<th>Salary</th>
32+
</tr>
33+
</thead>
34+
<tbody>
35+
<tr ng-repeat="row in rows">
36+
<td ng-repeat="value in row">{{value}}</td>
37+
</tr>
38+
</tbody>
39+
<tfoot>
40+
<tr>
41+
<th>Name</th>
42+
<th>Position</th>
43+
<th>Office</th>
44+
<th>Age</th>
45+
<th>Start date</th>
46+
<th>Salary</th>
47+
</tr>
48+
</tfoot>
49+
</table>
50+
</body>
51+
</html>

0 commit comments

Comments
 (0)