$column->{cannot_be_toggled} = $c->cannot_be_toggled;
}
- return $list->{modules}{$module}{$page}{$tablename} || [];
+ my $columns = $list->{modules}{$module}{$page}{$tablename} || [];
+
+ # Assign default value if does not exist
+ $columns = [ map {
+ {
+ cannot_be_toggled => exists $_->{cannot_be_toggled} ? $_->{cannot_be_toggled} : 0,
+ is_hidden => exists $_->{is_hidden} ? $_->{is_hidden} : 0,
+ columnname => $_->{columnname},
+ }
+ } @$columns ];
+
+ return $columns;
}
sub get_modules {
[% USE ColumnsSettings %]
-<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.colvis.css" />
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.colvis.js"></script>
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/buttons.dataTables.min.css" />
+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/dataTables.buttons.min.js"></script>
+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/buttons.colVis.min.js"></script>
<script type="text/javascript">
function KohaTable(selector, dt_parameters, columns_settings) {
var id = 0;
var hidden_ids = [];
- var excluded_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 ( this['is_hidden'] == "1" ) {
hidden_ids.push( used_id );
}
- if ( this['cannot_be_toggled'] == "1" ) {
- excluded_ids.push( used_id );
+ if ( this['cannot_be_toggled'] == "0" ) {
+ included_ids.push( used_id );
}
id++;
});
- dt_parameters[ "oColVis" ] = { "aiExclude": excluded_ids };
+ dt_parameters[ "buttons" ] = [
+ {
+ extend: 'colvis',
+ columns: included_ids,
+ }
+ ];
var table = $(selector).dataTable($.extend(true, {}, dataTablesDefaults, dt_parameters));
$(hidden_ids).each(function(index, value) {
[% INCLUDE 'format_price.inc' %]
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/dataTables.buttons.min.js"></script>
+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/buttons.colVis.min.js"></script>
<script type="text/javascript">
//<![CDATA[
var MSG_DT_FIRST = _("First");
"sSearch" : window.MSG_DT_SEARCH || "Search:",
"sZeroRecords" : window.MSG_DT_ZERO_RECORDS || "No matching records found"
},
- "sDom": 'C<"top pager"ilpf>tr<"bottom pager"ip>',
+ "dom": '<"top pager"ilpfB>tr<"bottom pager"ip>',
"aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]],
"iDisplayLength": 20
};