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

Commit d432606

Browse files
committed
Set default DOM options in DTDefaultOptions #632
1 parent 67da9c3 commit d432606

23 files changed

+79
-47
lines changed

demo/api/apiDefaultOptions.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ <h3><code>DTDefaultOptions</code></h3>
7474
}
7575
});
7676
});
77+
</div>
78+
</td>
79+
</tr>
80+
<tr>
81+
<td><code>DTDefaultOptions</code></td>
82+
<td><code>setDOM(sDom)</code></td>
83+
<td>
84+
Set the default <a href="https://datatables.net/reference/option/dom">DOM</a> for all DataTables.
85+
<div hljs language="js">
86+
angular.module('myModule', ['datatables']).run(function(DTDefaultOptions) {
87+
DTDefaultOptions.setDOM('lpfrtip');
88+
});
7789
</div>
7890
</td>
7991
</tr>

dist/angular-datatables.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ function dtOptionsBuilder() {
155155
* @param fnPromise the function that returns a promise to fetch the data
156156
*/
157157
var DTOptions = {
158-
hasOverrideDom: false,
159-
160158
/**
161159
* Add the option to the datatables options
162160
* @param key the key of the option
@@ -595,8 +593,6 @@ function initAngularDataTables() {
595593
'use strict';
596594
angular.module('datatables.options', [])
597595
.constant('DT_DEFAULT_OPTIONS', {
598-
// Default dom
599-
dom: 'lfrtip',
600596
// Default ajax properties. See http://legacy.datatables.net/usage/options#sAjaxDataProp
601597
sAjaxDataProp: '',
602598
// Set default columns (used when none are provided)
@@ -613,7 +609,8 @@ function dtDefaultOptions() {
613609
setLanguageSource: setLanguageSource,
614610
setLanguage: setLanguage,
615611
setDisplayLength: setDisplayLength,
616-
setBootstrapOptions: setBootstrapOptions
612+
setBootstrapOptions: setBootstrapOptions,
613+
setDOM: setDOM
617614
};
618615

619616
return options;
@@ -683,6 +680,19 @@ function dtDefaultOptions() {
683680
options.bootstrapOptions = oBootstrapOptions;
684681
return options;
685682
}
683+
684+
/**
685+
* Set the DOM for all DataTables.
686+
* See https://datatables.net/reference/option/dom
687+
* @param dom the dom
688+
* @returns {DTDefaultoptions} the default option config
689+
*/
690+
function setDOM(dom) {
691+
$.extend($.fn.dataTable.defaults, {
692+
sDom: dom
693+
});
694+
return options;
695+
}
686696
}
687697

688698
'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.

dist/plugins/bootstrap/angular-datatables.bootstrap.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ initBootstrapPlugin.$inject = ['DTRendererService', 'DTBootstrap'];
139139
* Source: https://editor.datatables.net/release/DataTables/extras/Editor/examples/bootstrap.html
140140
*/
141141
/* @ngInject */
142-
function dtBootstrap(DTBootstrapTableTools, DTBootstrapColVis, DTBootstrapDefaultOptions, DTPropertyUtil, DT_DEFAULT_OPTIONS) {
142+
function dtBootstrap(DTBootstrapTableTools, DTBootstrapColVis, DTBootstrapDefaultOptions, DTPropertyUtil) {
143143
var _initialized = false,
144144
_drawCallbackFunctionList = [],
145145
_savedFn = {};
@@ -357,7 +357,7 @@ function dtBootstrap(DTBootstrapTableTools, DTBootstrapColVis, DTBootstrapDefaul
357357
}
358358

359359
function _setDom(options) {
360-
if (!options.dom || options.dom === DT_DEFAULT_OPTIONS.dom) {
360+
if (!options.dom || options.dom === $.fn.dataTable.defaults.sDom) {
361361
return DTBootstrapDefaultOptions.getOptions().dom;
362362
}
363363
return options.dom;
@@ -391,7 +391,7 @@ function dtBootstrap(DTBootstrapTableTools, DTBootstrapColVis, DTBootstrapDefaul
391391
}
392392
}
393393
}
394-
dtBootstrap.$inject = ['DTBootstrapTableTools', 'DTBootstrapColVis', 'DTBootstrapDefaultOptions', 'DTPropertyUtil', 'DT_DEFAULT_OPTIONS'];
394+
dtBootstrap.$inject = ['DTBootstrapTableTools', 'DTBootstrapColVis', 'DTBootstrapDefaultOptions', 'DTPropertyUtil'];
395395

396396
'use strict';
397397
angular.module('datatables.bootstrap.options', ['datatables.options', 'datatables.util'])

dist/plugins/bootstrap/angular-datatables.bootstrap.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.

dist/plugins/buttons/angular-datatables.buttons.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ angular.module('datatables.buttons', ['datatables'])
1616
.run(initButtonsPlugin);
1717

1818
/* @ngInject */
19-
function dtButtonsConfig($provide, DT_DEFAULT_OPTIONS) {
19+
function dtButtonsConfig($provide) {
2020
$provide.decorator('DTOptionsBuilder', dtOptionsBuilderDecorator);
2121

2222
function dtOptionsBuilderDecorator($delegate) {
@@ -48,7 +48,7 @@ function dtButtonsConfig($provide, DT_DEFAULT_OPTIONS) {
4848
*/
4949
function withButtons(buttonsOptions) {
5050
var buttonsPrefix = 'B';
51-
options.dom = options.dom ? options.dom : DT_DEFAULT_OPTIONS.dom;
51+
options.dom = options.dom ? options.dom : $.fn.dataTable.defaults.sDom;
5252
if (options.dom.indexOf(buttonsPrefix) === -1) {
5353
options.dom = buttonsPrefix + options.dom;
5454
}
@@ -62,7 +62,7 @@ function dtButtonsConfig($provide, DT_DEFAULT_OPTIONS) {
6262
}
6363
dtOptionsBuilderDecorator.$inject = ['$delegate'];
6464
}
65-
dtButtonsConfig.$inject = ['$provide', 'DT_DEFAULT_OPTIONS'];
65+
dtButtonsConfig.$inject = ['$provide'];
6666

6767
/* @ngInject */
6868
function initButtonsPlugin(DTRendererService) {

0 commit comments

Comments
 (0)