Revision: 1960
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1960&view=rev
Author:   cimorrison
Date:     2011-09-20 15:19:06 +0000 (Tue, 20 Sep 2011)
Log Message:
-----------
Made start and end times in the report table sort and filter properly

Modified Paths:
--------------
    mrbs/branches/datatables/web/Themes/default/header.inc
    mrbs/branches/datatables/web/jquery/datatables/js/plugins.js
    mrbs/branches/datatables/web/report.php

Modified: mrbs/branches/datatables/web/Themes/default/header.inc
===================================================================
--- mrbs/branches/datatables/web/Themes/default/header.inc      2011-09-20 
14:18:13 UTC (rev 1959)
+++ mrbs/branches/datatables/web/Themes/default/header.inc      2011-09-20 
15:19:06 UTC (rev 1960)
@@ -1380,8 +1380,11 @@
     <?php 
     // Stop the first column ("id") from being searchable.   For some reason
     // using bVisible here does not work, so we will use CSS instead.
+    // Define the type of the start and end time columns (they have the
+    // Unix timestamp in the title of a span for sorting)
     ?>
-    tableOptions.aoColumnDefs = [{"bSearchable": false, "bVisible": false, 
"aTargets": [ 0 ]}]; 
+    tableOptions.aoColumnDefs = [{"bSearchable": false, "bVisible": false, 
"aTargets": [ 0 ]},
+                                 {"sType": "title-numeric", "aTargets": [3, 
4]}]; 
 
     <?php
     // Fix the left hand three columns (one of which is the "id" column which

Modified: mrbs/branches/datatables/web/jquery/datatables/js/plugins.js
===================================================================
--- mrbs/branches/datatables/web/jquery/datatables/js/plugins.js        
2011-09-20 14:18:13 UTC (rev 1959)
+++ mrbs/branches/datatables/web/jquery/datatables/js/plugins.js        
2011-09-20 15:19:06 UTC (rev 1960)
@@ -8,7 +8,7 @@
     a.push(oSettings.aoData[ oSettings.aiDisplay[i] ]._aData);
   }
   return a;
-}
+};
 
 
 $.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, 
fnCallback, bStandingRedraw )
@@ -48,5 +48,30 @@
       fnCallback( oSettings );
     }
   }, oSettings );
-}
+};
 
+
+// Sorting plugins
+
+$.fn.dataTableExt.oSort['title-numeric-asc']  = function(a,b) {
+  var x = a.match(/title="*(-?[0-9\.]+)/)[1];
+  var y = b.match(/title="*(-?[0-9\.]+)/)[1];
+  x = parseFloat( x );
+  y = parseFloat( y );
+  return ((x < y) ? -1 : ((x > y) ?  1 : 0));
+  };
+
+$.fn.dataTableExt.oSort['title-numeric-desc'] = function(a,b) {
+  var x = a.match(/title="*(-?[0-9\.]+)/)[1];
+  var y = b.match(/title="*(-?[0-9\.]+)/)[1];
+  x = parseFloat( x );
+  y = parseFloat( y );
+  return ((x < y) ?  1 : ((x > y) ? -1 : 0));
+  };
+
+// Filtering plugins
+
+$.fn.dataTableExt.ofnSearch['title-numeric'] = function ( sData ) {
+   return sData.replace(/\n/g," ").replace( /<.*?>/g, "" );
+   };
+

Modified: mrbs/branches/datatables/web/report.php
===================================================================
--- mrbs/branches/datatables/web/report.php     2011-09-20 14:18:13 UTC (rev 
1959)
+++ mrbs/branches/datatables/web/report.php     2011-09-20 15:19:06 UTC (rev 
1960)
@@ -225,9 +225,9 @@
   }
   else
   {
-    // Include the numeric start time in a non-displayed span so that
-    // the column can be sorted properly
-    $values[] = "<span>" . $row['start_time'] . "</span>" . 
escape($start_date);
+    // Include the numeric start time as a title in an empty span so
+    // that the column can be sorted and filtered properly
+    $values[] = "<span title=\"" . $row['start_time'] . "\"></span>" . 
escape($start_date);
   }
   
   // End date
@@ -245,9 +245,9 @@
   }
   else
   {
-    // Include the numeric start time in a non-displayed span so that
-    // the column can be sorted properly
-    $values[] = "<span>" . $row['end_time'] . "</span>" . escape($end_date);
+    // Include the numeric end time as a title in an empty span so
+    // that the column can be sorted and filtered properly
+    $values[] = "<span title=\"" . $row['end_time'] . "\"></span>" . 
escape($end_date);
   }
   
   // Duration

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to