Revision: 2517
https://sourceforge.net/p/mrbs/code/2517/
Author: cimorrison
Date: 2012-10-22 15:19:54 +0000 (Mon, 22 Oct 2012)
Log Message:
-----------
Restructured code to be more resilient to changes in report column order
Modified Paths:
--------------
mrbs/trunk/web/js/report.js.php
mrbs/trunk/web/report.php
Modified: mrbs/trunk/web/js/report.js.php
===================================================================
--- mrbs/trunk/web/js/report.js.php 2012-10-22 14:06:42 UTC (rev 2516)
+++ mrbs/trunk/web/js/report.js.php 2012-10-22 15:19:54 UTC (rev 2517)
@@ -182,11 +182,32 @@
value: '1'
}).appendTo('#report_form');
}
+
+ var table = $('#report_table');
+
<?php
- // Define the type of the start time, end time, duration and last updated
columns
- // (they have the Unix timestamp in the title of a span for sorting)
+ // Get the sTypes (which are in a data-sType in a <span> in the <th>) and
+ // feed those into dataTables
?>
- tableOptions.aoColumnDefs = [{"sType": "title-numeric", "aTargets": [3, 4,
5, -1]}];
+ var sTypes = {};
+ table.find('thead tr:first th').each(function(i) {
+ var type = $(this).find('span').data('stype');
+ if (type)
+ {
+ if (sTypes[type] === undefined)
+ {
+ sTypes[type] = [];
+ }
+ sTypes[type].push(i);
+ }
+ });
+ tableOptions.aoColumnDefs = [];
+ var type;
+ for (type in sTypes)
+ {
+ tableOptions.aoColumnDefs.push({sType: type,
+ aTargets: sTypes[type]});
+ }
<?php
// Fix the left hand column. This has to be done when initialisation is
@@ -199,7 +220,6 @@
// width. (Unfortunately the actual column width is just the width of
the
// column on the first page)
?>
- var table = $('#report_table');
var leftWidth = getFixedColWidth(table, {sWidth: "relative", iWidth:
33});
var oFC = new FixedColumns(reportTable, {"iLeftColumns": 1,
"iLeftWidth": leftWidth,
Modified: mrbs/trunk/web/report.php
===================================================================
--- mrbs/trunk/web/report.php 2012-10-22 14:06:42 UTC (rev 2516)
+++ mrbs/trunk/web/report.php 2012-10-22 15:19:54 UTC (rev 2517)
@@ -69,6 +69,7 @@
foreach ($field_order_list as $field)
{
+ // We give some columns an stype data value so that the JavaScript knows
how to sort them
switch ($field)
{
case 'name':
@@ -81,11 +82,11 @@
$values[] = get_vocab("room");
break;
case 'start_time':
- $values[] = get_vocab("start_date");
+ $values[] = '<span class="normal" data-stype="title-numeric">' .
get_vocab("start_date") . '</span>';
break;
case 'end_time':
- $values[] = get_vocab("end_date");
- $values[] = get_vocab("duration");
+ $values[] = '<span class="normal" data-stype="title-numeric">' .
get_vocab("end_date") . '</span>';
+ $values[] = '<span class="normal" data-stype="title-numeric">' .
get_vocab("duration") . '</span>';
break;
case 'description':
$values[] = get_vocab("fulldescription_short");
@@ -109,7 +110,7 @@
}
break;
case 'last_updated':
- $values[] = get_vocab("lastupdate");
+ $values[] = '<span class="normal" data-stype="title-numeric">' .
get_vocab("lastupdate") . '</span>';
break;
default:
// the custom fields
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits