1 [% USE ColumnsSettings %]
4 function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) {
8 var selector = '#' + id_selector;
10 $(columns_settings).each( function() {
11 var named_id = $( 'thead th[data-colname="' + this.columnname + '"]', selector ).index( 'th' );
12 var used_id = dt_parameters.bKohaColumnsUseNames ? named_id : counter;
13 if ( used_id == -1 ) return;
15 if ( this['is_hidden'] == "1" ) {
16 hidden_ids.push( used_id );
18 if ( this['cannot_be_toggled'] == "0" ) {
19 included_ids.push( used_id );
24 var exportColumns = ":visible:not(.noExport)";
25 if( dt_parameters.hasOwnProperty("exportColumns") ){
26 // A custom buttons configuration has been passed from the page
27 exportColumns = dt_parameters["exportColumns"];
30 var export_buttons = [
35 columns: exportColumns
42 columns: exportColumns
49 columns: exportColumns
56 columns: exportColumns
61 dt_parameters[ "buttons" ] = [
64 className: "dt_button_clear_filter",
65 titleAttr: _("Clear filter"),
67 text: '<i class="fa fa-lg fa-remove"></i> <span class="dt-button-text">' + _("Clear filter") + '</span>',
68 action: function ( e, dt, node, config ) {
69 dt.search( "" ).draw("page");
70 node.addClass("disabled");
76 columns: included_ids,
77 className: "columns_controls",
78 titleAttr: _("Columns settings"),
79 text: '<i class="fa fa-lg fa-gear"></i> <span class="dt-button-text">' + _("Columns") + '</span>',
81 columns: exportColumns
88 className: "export_controls",
89 titleAttr: _("Export or print"),
90 text: '<i class="fa fa-lg fa-download"></i> <span class="dt-button-text">' + _("Export") + '</span>',
91 buttons: export_buttons
96 var table = $(selector);
98 // Duplicate the table header row for columnFilter
99 thead_row = table.find('thead tr');
100 clone = thead_row.clone().addClass('filters_row');
101 clone.find("th.NoSort").html('');
102 thead_row.before(clone);
105 table.dataTable($.extend(true, {}, dataTablesDefaults, dt_parameters));
107 $(hidden_ids).each(function(index, value) {
108 table.fnSetColumnVis( value, false );
112 // show a link to activate filtering
115 .attr('id', id_selector + '_activate_filters');
116 $("." + id_selector + "_table_controls").prepend(link);
117 deactivate_filters(id_selector);
120 $(".dt_button_clear_filter, .columns_controls, .export_controls").tooltip();