var events_list = (function ($, window, jQuery) { var _vars_ = {}; return { set_vars: function (options) { $.extend(_vars_, options || {}); }, get_vars : function(){ return _vars_; }, load : function(){ var table = $('#events_list').DataTable({ "autoWidth": false, "responsive": true, "processing": true, //Feature control the processing indicator. "serverSide": true, //Feature control DataTables' server-side processing mode. "order": [[1,"desc"]], //Initial no order. "oLanguage": fr_onload_lang.oLanguage, // Load data for the table's content from an Ajax source "ajax": { "url": app.get_vars().baseurl+"reports/events/get_events_list/0", "type": "POST" }, "columns": [ { "data": "event_order" }, { "data": "event_title" }, { "data": "event_type" }, { "data": "city" }, { "data": "author" }, { "data": "date_created" }, { "data": "event_status" }, { "data": "action" , render : function(data, type, full, meta){ return ''+ ' '+ app.get_vars().reports.btn._export+ ''; }}, { "data": "bo_status" } ], "fnDrawCallback": function() { app._tooltip._hide(); $('#events_list tbody tr td').each( function(x, y) { var _this = $(this); if(_this.hasClass('truncate-content-text')){ _this.css('max-width', '150px'); this.setAttribute( 'title', _this.text()); this.setAttribute( 'data-toggle',"tooltip"); } }); app._tooltip._pop(); }, "columnDefs": [ {"targets": [0], "orderable": false, width : "1%"}, {"targets": [7], "orderable": false, width : "2%"}, { "targets": [1], className : "truncate-content-text custom-popover-tooltip"}, { "targets": [6], width : "2%"}, { "targets": [5], width : "2%"}, { "targets": [2], width : "2%"} ], "initComplete": function(settings, json) { //run tooltip app._tooltip._hide(); app._tooltip._pop(); //fire search filter event app.grid.search_filter("events_list", events_list.get_vars().events); } }); events_list.set_vars({events : table}); }, _export : function(ev){ var event_id = $(ev).data("eid"); var data = (events_list.get_vars().events).ajax.params(); $(ev).attr("href", app.get_vars().baseurl+"export_events_list/"+event_id+"?" + $.param(data)); } };//end of return // Pass in jQuery. })(jQuery, this); $(function() { events_list.load(); });