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

Commit 8629234

Browse files
committed
#35 Add the possibility to override loading template
1 parent d042a63 commit 8629234

9 files changed

+59
-7
lines changed

demo/app.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
$rootScope.$broadcast('event:changeView', 'zeroConfig');
2525
}
2626
})
27+
.state('overrideLoadingTpl', {
28+
url: '/overrideLoadingTpl',
29+
templateUrl: 'demo/partials/override_loading_tpl.html',
30+
controller: function($rootScope) {
31+
$rootScope.$broadcast('event:changeView', 'overrideLoadingTpl');
32+
}
33+
})
2734
.state('withOptions', {
2835
url: '/withOptions',
2936
templateUrl: 'demo/partials/with_options.html',
@@ -144,6 +151,11 @@
144151
.withColVis()
145152
.withOption('bAutoWidth', false)
146153
.withTableTools('vendor/datatables-tabletools/swf/copy_csv_xls_pdf.swf');
154+
})
155+
.factory('DTLoadingTemplate', function() {
156+
return {
157+
html: '<h3>Loading great stuffs!!!</h3>'
158+
};
147159
});
148160

149161
backToTop.init({
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<article class="main-content">
2+
<header class="article-header">
3+
<h1><i class="fa fa-play"></i>&nbsp;Override <code>Loading</code> template</h1>
4+
</header>
5+
<section class="article-content">
6+
<p>
7+
When loading data, the angular module will display <code>&lt;h3 class="dt-loading"&gt;Loading...&lt;/h3&gt;</code>.
8+
</p>
9+
<p>
10+
You can make your own custom loading html by override the <code>DTLoadingTemplate</code> like this:
11+
</p>
12+
</section>
13+
<section class="showcase no-tab">
14+
<div hljs>
15+
angular.module('datatablesSampleApp', ['datatables']).
16+
factory('DTLoadingTemplate', function() {
17+
return {
18+
html: '<h1>CUSTOM LOADING</h1>'
19+
};
20+
});
21+
</div>
22+
</section>
23+
</article>

demo/partials/sidebar.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
<i class="menu-icon fa fa-caret-right"></i>&nbsp;Data reload with promise
4141
</a>
4242
</li>
43+
<li ng-class="{'active': isActive('overrideLoadingTpl')}">
44+
<a ui-sref="overrideLoadingTpl">
45+
<i class="menu-icon fa fa-caret-right"></i>&nbsp;Custom loading HTML
46+
</a>
47+
</li>
4348
<li ng-class="{'active': isActive('serverSideProcessing')}">
4449
<a ui-sref="serverSideProcessing">
4550
<i class="menu-icon fa fa-caret-right"></i>&nbsp;Server side processing

dist/angular-datatables.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,9 @@
311311
'$timeout',
312312
'DT_LAST_ROW_KEY',
313313
'$DTBootstrap',
314-
function (DT_DEFAULT_OPTIONS, $timeout, DT_LAST_ROW_KEY, $DTBootstrap) {
315-
var $loading = angular.element('<h3>Loading...</h3>'), _showLoading = function ($elem) {
314+
'DTLoadingTemplate',
315+
function (DT_DEFAULT_OPTIONS, $timeout, DT_LAST_ROW_KEY, $DTBootstrap, DTLoadingTemplate) {
316+
var $loading = angular.element(DTLoadingTemplate.html), _showLoading = function ($elem) {
316317
$elem.after($loading);
317318
$elem.hide();
318319
}, _hideLoading = function ($elem) {
@@ -867,7 +868,9 @@
867868
}
868869
};
869870
}
870-
]);
871+
]).factory('DTLoadingTemplate', function () {
872+
return { html: '<h3 class="dt-loading">Loading...</h3>' };
873+
});
871874
}(jQuery, angular));
872875
(function (angular) {
873876
'use strict';

dist/angular-datatables.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"grunt": "~0.4.1",
88
"grunt-express": "1.2.0",
99
"grunt-contrib-watch": "~0.5.2",
10-
"grunt-contrib-clean": "~0.5.0",
10+
"grunt-contrib-clean": "0.5.0",
1111
"grunt-contrib-concat": "~0.3.0",
1212
"grunt-contrib-cssmin": "~0.7.0",
1313
"grunt-contrib-jshint": "~0.7.1",

src/angular-datatables.directive.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
sAjaxDataProp: '',
77
aoColumns: []
88
}).
9-
directive('datatable', function(DT_DEFAULT_OPTIONS, $timeout, DT_LAST_ROW_KEY, $DTBootstrap) {
10-
var $loading = angular.element('<h3>Loading...</h3>'),
9+
directive('datatable', function(DT_DEFAULT_OPTIONS, $timeout, DT_LAST_ROW_KEY, $DTBootstrap, DTLoadingTemplate) {
10+
var $loading = angular.element(DTLoadingTemplate.html),
1111
_showLoading = function ($elem) {
1212
$elem.after($loading);
1313
$elem.hide();

src/angular-datatables.factory.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,5 +512,10 @@
512512
return column;
513513
}
514514
};
515+
}).
516+
factory('DTLoadingTemplate', function() {
517+
return {
518+
html: '<h3 class="dt-loading">Loading...</h3>'
519+
};
515520
});
516521
})(jQuery, angular);

styles/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ pre code {
208208
border-bottom: 1px solid #c2c2c2;
209209
}
210210

211+
.showcase.no-tab {
212+
border-top: 1px solid #c2c2c2;
213+
}
214+
211215
.api .showcase .tab-content {
212216
padding: 10px
213217
}

0 commit comments

Comments
 (0)