- /* Transforms the table into DataTable, and keep a pointer to it */
- actual_options = {
- // Customize the position of Datatables elements (length,filter,button,...)
- // we use a fluid row on top and another on the bottom, making sure we take 12 grid elt's each time
- sDom: "<'row-fluid'<'span5'l><'span1'r><'span6'f>>t<'row-fluid'<'span5'i><'span7'p>>",
- sPaginationType: 'bootstrap',
- // Handle the null values & the error : Datatables warning Requested unknown parameter
- // http://datatables.net/forums/discussion/5331/datatables-warning-...-requested-unknown-parameter/p2
- aoColumnDefs: [{sDefaultContent: '',aTargets: [ '_all' ]}],
- // WARNING: this one causes tables in a 'tabs' that are not exposed at the time this is run to show up empty
- // sScrollX: '100%', /* Horizontal scrolling */
- bProcessing: true, /* Loading */
- fnDrawCallback: function() { hazelnut_draw_callback.call(object, options); }
- };
- // the intention here is that options.datatables_options as coming from the python object take precedence
- // XXX DISABLED by jordan: was causing errors in datatables.js $.extend(actual_options, options.datatables_options );
- this.table = $('#hazelnut-' + options.plugin_uuid).dataTable(actual_options);
-
- /* Setup the SelectAll button in the dataTable header */
- /* xxx not sure this is still working */
- var oSelectAll = $('#datatableSelectAll-'+ options.plugin_uuid);
- oSelectAll.html("<span class='ui-icon ui-icon-check' style='float:right;display:inline-block;'></span>Select All");
- oSelectAll.button();
- oSelectAll.css('font-size','11px');
- oSelectAll.css('float','right');
- oSelectAll.css('margin-right','15px');
- oSelectAll.css('margin-bottom','5px');
- oSelectAll.unbind('click');
- oSelectAll.click(selectAll);
-
- /* Add a filtering function to the current table
- * Note: we use closure to get access to the 'options'
- */
- $.fn.dataTableExt.afnFiltering.push(function( oSettings, aData, iDataIndex ) {
- /* No filtering if the table does not match */
- if (oSettings.nTable.id != "hazelnut-" + options.plugin_uuid)
- return true;
- return hazelnut_filter.call(object, oSettings, aData, iDataIndex);
- });
+ this.initialize = function() {
+ /* Transforms the table into DataTable, and keep a pointer to it */
+ actual_options = {
+ // Customize the position of Datatables elements (length,filter,button,...)
+ // we use a fluid row on top and another on the bottom, making sure we take 12 grid elt's each time
+ sDom: "<'row-fluid'<'span5'l><'span1'r><'span6'f>>t<'row-fluid'<'span5'i><'span7'p>>",
+ sPaginationType: 'bootstrap',
+ // Handle the null values & the error : Datatables warning Requested unknown parameter
+ // http://datatables.net/forums/discussion/5331/datatables-warning-...-requested-unknown-parameter/p2
+ aoColumnDefs: [{sDefaultContent: '',aTargets: [ '_all' ]}],
+ // WARNING: this one causes tables in a 'tabs' that are not exposed at the time this is run to show up empty
+ // sScrollX: '100%', /* Horizontal scrolling */
+ bProcessing: true, /* Loading */
+ fnDrawCallback: function() { hazelnut_draw_callback.call(object, options); }
+ };
+ // the intention here is that options.datatables_options as coming from the python object take precedence
+ // XXX DISABLED by jordan: was causing errors in datatables.js $.extend(actual_options, options.datatables_options );
+ this.table = $('#hazelnut-' + options.plugin_uuid).dataTable(actual_options);
+
+ /* Setup the SelectAll button in the dataTable header */
+ /* xxx not sure this is still working */
+ var oSelectAll = $('#datatableSelectAll-'+ options.plugin_uuid);
+ oSelectAll.html("<span class='ui-icon ui-icon-check' style='float:right;display:inline-block;'></span>Select All");
+ oSelectAll.button();
+ oSelectAll.css('font-size','11px');
+ oSelectAll.css('float','right');
+ oSelectAll.css('margin-right','15px');
+ oSelectAll.css('margin-bottom','5px');
+ oSelectAll.unbind('click');
+ oSelectAll.click(selectAll);
+
+ /* Add a filtering function to the current table
+ * Note: we use closure to get access to the 'options'
+ */
+ $.fn.dataTableExt.afnFiltering.push(function( oSettings, aData, iDataIndex ) {
+ /* No filtering if the table does not match */
+ if (oSettings.nTable.id != "hazelnut-" + options.plugin_uuid)
+ return true;
+ return hazelnut_filter.call(object, oSettings, aData, iDataIndex);
+ });
+
+ /* Processing hidden_columns */
+ $.each(options.hidden_columns, function(i, field) {
+ object.hide_column(field);
+ });
+ }