Skip to content

Commit b2a5464

Browse files
committed
Added option "selectAllRender" that defines "Select all" control markup
1 parent e511bbc commit b2a5464

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

js/dataTables.checkboxes.js

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/*! Checkboxes 1.2.7
1+
/*! Checkboxes 1.2.8
22
* Copyright (c) Gyrocode (www.gyrocode.com)
33
* License: MIT License
44
*/
55

66
/**
77
* @summary Checkboxes
88
* @description Checkboxes extension for jQuery DataTables
9-
* @version 1.2.7
9+
* @version 1.2.8
1010
* @file dataTables.checkboxes.js
1111
* @author Gyrocode (http://www.gyrocode.com/projects/jquery-datatables-checkboxes/)
1212
* @contact http://www.gyrocode.com/contacts
@@ -214,10 +214,24 @@ Checkboxes.prototype = {
214214
// Save previous HTML content
215215
$colHeader.data('html', $colHeader.html());
216216

217-
$colHeader
218-
.html('<input type="checkbox">')
219-
.addClass('dt-checkboxes-select-all')
220-
.attr('data-col', i);
217+
// If "Select all" control markup is provided
218+
if(ctx.aoColumns[i].checkboxes.selectAllRender !== null){
219+
var selectAllHtml = '';
220+
221+
// If "selectAllRender" option is a function
222+
if($.isFunction(ctx.aoColumns[i].checkboxes.selectAllRender)){
223+
selectAllHtml = ctx.aoColumns[i].checkboxes.selectAllRender();
224+
225+
// Otherwise, if "selectAllRender" option is a string
226+
} else if(typeof ctx.aoColumns[i].checkboxes.selectAllRender === 'string'){
227+
selectAllHtml = ctx.aoColumns[i].checkboxes.selectAllRender;
228+
}
229+
230+
$colHeader
231+
.html(selectAllHtml)
232+
.addClass('dt-checkboxes-select-all')
233+
.attr('data-col', i);
234+
}
221235
}
222236
}
223237
}
@@ -870,7 +884,15 @@ Checkboxes.defaults = {
870884
* @type {Function}
871885
* @default `null`
872886
*/
873-
selectAllCallback: null
887+
selectAllCallback: null,
888+
889+
/**
890+
* "Select all" control markup
891+
*
892+
* @type {mixed}
893+
* @default `<input type="checkbox">`
894+
*/
895+
selectAllRender: '<input type="checkbox">'
874896
};
875897

876898

@@ -1000,7 +1022,7 @@ Api.registerPlural( 'cells().checkboxes.enable()', 'cell().checkboxes.enable()',
10001022
// If data is in the list
10011023
if(ctx.checkboxes.s.data[colIdx].hasOwnProperty(cellData)){
10021024
// Update selection based on current state:
1003-
// if checkbox is enabled then select row;
1025+
// if checkbox is enabled then select row;
10041026
// otherwise, deselect row
10051027
ctx.checkboxes.updateSelect(rowIdx, state);
10061028
}
@@ -1061,7 +1083,7 @@ Api.registerPlural( 'columns().checkboxes.selected()', 'column().checkboxes.sele
10611083
* @name Checkboxes.version
10621084
* @static
10631085
*/
1064-
Checkboxes.version = '1.2.7';
1086+
Checkboxes.version = '1.2.8';
10651087

10661088

10671089

0 commit comments

Comments
 (0)