Koha/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc
Jonathan Druart aed235cbf5 Bug 15921: Do not include datatables js/css files twice
datatables.inc loads dataTables.buttons.min.js and buttons.colVis.min.js
since bug 15285: Update common files because the dom param now contains
'B'. The DT init fails with it does not know what 'B' means.

Test plan:
Test tables using buttons (columns visibility), they should work as
before this patch.

Tested with patron search and administration/currencies, works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
2016-03-24 15:50:02 +00:00

37 lines
1 KiB
PHP

[% USE ColumnsSettings %]
<script type="text/javascript">
function KohaTable(selector, dt_parameters, columns_settings) {
var id = 0;
var hidden_ids = [];
var included_ids = [];
$(columns_settings).each( function() {
var named_id = $( 'thead th[data-colname="' + this.columnname + '"]', selector ).index( 'th' );
var used_id = dt_parameters.bKohaColumnsUseNames ? named_id : id;
if ( used_id == -1 ) return;
if ( this['is_hidden'] == "1" ) {
hidden_ids.push( used_id );
}
if ( this['cannot_be_toggled'] == "0" ) {
included_ids.push( used_id );
}
id++;
});
dt_parameters[ "buttons" ] = [
{
extend: 'colvis',
columns: included_ids,
text: _("Column visibility"),
}
];
var table = $(selector).dataTable($.extend(true, {}, dataTablesDefaults, dt_parameters));
$(hidden_ids).each(function(index, value) {
table.fnSetColumnVis( value, false );
});
return table;
}
</script>