Skip to content

Commit 960b021

Browse files
author
Allan Jardine
committed
New: -button collection button type now has a collectionTitle that can be used to show a title at the top of a collection. This can be useful for use with multi-level collections to ensure the end user knows what the collection refers to.
1 parent e43cb0f commit 960b021

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

css/common.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ div.dt-button-info {
2525
padding: 1em;
2626
}
2727
}
28+
29+
div.dt-button-collection-title {
30+
text-align: center;
31+
padding: 0.3em 0 0.5em;
32+
font-size: 0.9em;
33+
}

docs/button/collection.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666
<option type="boolean" name="dropup" default="false">
6767
When `true`, the dropdown collection always drops up. When `false`, the collection drops down or up depending on the available overflow.
6868
</option>
69+
70+
<option type="string" name="collectionTitle" default="" since="1.5.4">
71+
A text string to show at the top of a collection. This can be useful for multi-level collections to ensure the end user knows what the current menu refers to.
72+
</option>
6973

7074

7175
<example title="DataTables initialisation: Create an export collection"><![CDATA[

examples/initialisation/collections-sub.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ $(document).ready(function() {
2525
dt.column( -1 ).visible( ! dt.column( -1 ).visible() );
2626
}
2727
},
28-
'colvis'
28+
{
29+
collectionTitle: 'Visibility control',
30+
extend: 'colvis'
31+
}
2932
]
3033
}
3134
]

js/dataTables.buttons.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ $.extend( Buttons.prototype, {
489489
var collectionDom = this.c.dom.collection;
490490
built.collection = $('<'+collectionDom.tag+'/>')
491491
.addClass( collectionDom.className )
492-
.attr( 'role', 'menu') ;
492+
.attr( 'role', 'menu' ) ;
493493
built.conf._collection = built.collection;
494494

495495
this._expandButton( built.buttons, built.conf.buttons, true, attachPoint );
@@ -1193,12 +1193,14 @@ $.extend( _dtButtons, {
11931193
insertPoint = document.body.lastChild;
11941194
}
11951195

1196+
config._collection.find('.dt-button-collection-title').remove();
1197+
config._collection.prepend('<div class="dt-button-collection-title">'+config.collectionTitle+'</div>');
1198+
11961199
config._collection
11971200
.addClass( config.collectionLayout )
11981201
.css( 'display', 'none' )
11991202
.insertAfter( insertPoint )
12001203
.fadeIn( config.fade );
1201-
12021204

12031205
var position = config._collection.css( 'position' );
12041206

@@ -1308,6 +1310,7 @@ $.extend( _dtButtons, {
13081310
},
13091311
background: true,
13101312
collectionLayout: '',
1313+
collectionTitle: '',
13111314
backgroundClassName: 'dt-button-background',
13121315
rightAlignClassName: 'dt-button-right',
13131316
autoClose: false,

0 commit comments

Comments
 (0)