Skip to content

Commit e43cb0f

Browse files
committed
New: Support for dropdown-menu-right in collection drops downs for Bootstrap 4
- GH #140
1 parent cfccff3 commit e43cb0f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

js/buttons.bootstrap4.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ $.extend( true, DataTable.Buttons.defaults, {
5757
} );
5858

5959
DataTable.ext.buttons.collection.className += ' dropdown-toggle';
60+
DataTable.ext.buttons.collection.rightAlignClassName = 'dropdown-menu-right';
6061

6162
return DataTable.Buttons;
6263
}));

js/dataTables.buttons.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,12 @@ $.extend( _dtButtons, {
12291229
config._collection.css( 'top', hostPosition.top - config._collection.outerHeight() - 5);
12301230
}
12311231

1232+
// Right alignment is enabled on a class, e.g. bootstrap:
1233+
// $.fn.dataTable.Buttons.defaults.dom.collection.className += " dropdown-menu-right";
1234+
if ( config._collection.hasClass( config.rightAlignClassName ) ) {
1235+
config._collection.css( 'left', hostPosition.left + host.outerWidth() - config._collection.outerWidth() );
1236+
}
1237+
12321238
// Right alignment in table container
12331239
var listRight = hostPosition.left + config._collection.outerWidth();
12341240
var tableRight = tableContainer.offset().left + tableContainer.width();
@@ -1303,6 +1309,7 @@ $.extend( _dtButtons, {
13031309
background: true,
13041310
collectionLayout: '',
13051311
backgroundClassName: 'dt-button-background',
1312+
rightAlignClassName: 'dt-button-right',
13061313
autoClose: false,
13071314
fade: 400,
13081315
attr: {

0 commit comments

Comments
 (0)