Bug 14510: Allow column visibility in additem.pl to be customized
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / includes / columns_settings.inc
1 [% USE ColumnsSettings %]
2
3 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.colvis.css" />
4 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.colvis.js"></script>
5
6 <script type="text/javascript">
7 function KohaTable(selector, dt_parameters, columns_settings) {
8     var id = 0;
9     var hidden_ids = [];
10     var excluded_ids = [];
11     $(columns_settings).each( function() {
12                 var named_id = $( 'thead th[data-colname="' + this.columnname + '"]', selector ).index( 'th' );
13                 var used_id = named_id == -1 ? id : named_id;
14
15         if ( this['is_hidden'] == "1" ) {
16             hidden_ids.push( used_id );
17         }
18         if ( this['cannot_be_toggled'] == "1" ) {
19             excluded_ids.push( used_id );
20         }
21         id++;
22     });
23     dt_parameters[ "oColVis" ] = { "aiExclude": excluded_ids };
24     var table = $(selector).dataTable($.extend(true, {}, dataTablesDefaults, dt_parameters));
25
26     $(hidden_ids).each(function(index, value) {
27         table.fnSetColumnVis( value, false );
28     });
29
30     return table;
31 }
32
33 </script>