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

Commit 83c239b

Browse files
committed
Refactoring demo
1 parent cc94151 commit 83c239b

Some content is hidden

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

75 files changed

+597
-826
lines changed

archives/v0.1.1/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<header class="header">
3535
<div class="container">
3636
<h1>
37-
<a href="/">angular-datatables</a>
37+
<a href="/">angular-datatables v0.1.1</a>
3838
<span class="header-icon hidden-xs hidden-sm">
3939
<a href="https://github.com/l-lin/angular-datatables/archive/v0.1.1.zip"><i class="fa fa-download"></i></a>
4040
</span>

archives/v0.2.0/favicon.png

-6.75 KB
Binary file not shown.

archives/v0.2.0/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<header class="header">
3535
<div class="container">
3636
<h1>
37-
<a href="/">angular-datatables</a>
37+
<a href="/">angular-datatables v0.2.0</a>
3838
<span class="header-icon hidden-xs hidden-sm">
3939
<a href="https://github.com/l-lin/angular-datatables/archive/v0.2.0.zip"><i class="fa fa-download"></i></a>
4040
</span>

demo/advanced/angularWayDataChange.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
angular.module('datatablesSampleApp').controller('angularWayChangeDataCtrl', function ($scope, $resource, DTOptionsBuilder, DTColumnDefBuilder) {
3+
var _buildPerson2Add = function (id) {
4+
return {
5+
id: id,
6+
firstName: 'Foo' + id,
7+
lastName: 'Bar' + id
8+
};
9+
};
10+
11+
$scope.persons = $resource('data1.json').query();
12+
$scope.dtOptions = DTOptionsBuilder.newOptions().withPaginationType('full_numbers');
13+
$scope.dtColumnDefs = [
14+
DTColumnDefBuilder.newColumnDef(0),
15+
DTColumnDefBuilder.newColumnDef(1),
16+
DTColumnDefBuilder.newColumnDef(2),
17+
DTColumnDefBuilder.newColumnDef(3).notSortable()
18+
];
19+
20+
$scope.person2Add = _buildPerson2Add(1);
21+
$scope.addPerson = function () {
22+
$scope.persons.push(angular.copy($scope.person2Add));
23+
$scope.person2Add = _buildPerson2Add($scope.person2Add.id + 1);
24+
};
25+
26+
$scope.modifyPerson = function (index) {
27+
$scope.persons.splice(index, 1, angular.copy($scope.person2Add))
28+
$scope.person2Add = _buildPerson2Add($scope.person2Add.id + 1);
29+
};
30+
31+
$scope.removePerson = function (index) {
32+
$scope.persons.splice(index, 1);
33+
};
34+
});

demo/advanced/bindAngularDirective.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
angular.module('datatablesSampleApp').controller('bindAngularDirectiveCtrl', function ($scope, $compile, DTOptionsBuilder, DTColumnBuilder) {
3+
$scope.message = '';
4+
$scope.edit = function(id) {
5+
$scope.message = 'You are trying to edit the row with ID: ' + id;
6+
// Edit some data and call server to make changes...
7+
// Then reload the data so that DT is refreshed
8+
$scope.dtOptions.reloadData();
9+
};
10+
$scope.delete = function(id) {
11+
$scope.message = 'You are trying to remove the row with ID: ' + id;
12+
// Delete some data and call server to make changes...
13+
// Then reload the data so that DT is refreshed
14+
$scope.dtOptions.reloadData();
15+
};
16+
17+
$scope.dtOptions = DTOptionsBuilder.fromSource('data1.json')
18+
.withPaginationType('full_numbers')
19+
.withOption('createdRow', function(row, data, dataIndex) {
20+
// Recompiling so we can bind Angular directive to the DT
21+
$compile(angular.element(row).contents())($scope);
22+
});
23+
$scope.dtColumns = [
24+
DTColumnBuilder.newColumn('id').withTitle('ID'),
25+
DTColumnBuilder.newColumn('firstName').withTitle('First name'),
26+
DTColumnBuilder.newColumn('lastName').withTitle('Last name'),
27+
DTColumnBuilder.newColumn(null).withTitle('Actions').notSortable()
28+
.renderWith(function(data, type, full, meta) {
29+
return '<button class="btn btn-warning" ng-click="edit(' + data.id + ')">' +
30+
' <i class="fa fa-edit"></i>' +
31+
'</button>&nbsp;' +
32+
'<button class="btn btn-danger" ng-click="delete(' + data.id + ')">' +
33+
' <i class="fa fa-trash-o"></i>' +
34+
'</button>';
35+
})
36+
];
37+
});
File renamed without changes.

demo/advanced/changeOptions.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
angular.module('datatablesSampleApp').controller('changeOptionsCtrl', function ($scope, DTOptionsBuilder, DTColumnDefBuilder) {
3+
$scope.dtOptions = DTOptionsBuilder.newOptions();
4+
$scope.dtColumnDefs = [
5+
DTColumnDefBuilder.newColumnDef(0),
6+
DTColumnDefBuilder.newColumnDef(1).notVisible(),
7+
DTColumnDefBuilder.newColumnDef(2).notSortable()
8+
];
9+
10+
$scope.changeOptions = function() {
11+
$scope.dtOptions = DTOptionsBuilder.newOptions()
12+
.withPaginationType('full_numbers')
13+
.withDisplayLength(2)
14+
.withDOM('pitrfl');
15+
};
16+
$scope.changeColumnDefs = function() {
17+
$scope.dtColumnDefs = [
18+
DTColumnDefBuilder.newColumnDef(0).notVisible(),
19+
DTColumnDefBuilder.newColumnDef(1).notVisible(),
20+
DTColumnDefBuilder.newColumnDef(2).notSortable()
21+
];
22+
};
23+
});

0 commit comments

Comments
 (0)