summaryrefslogtreecommitdiffstats
path: root/modules-available/js_stupidtable
diff options
context:
space:
mode:
authorUdo Walter2017-09-13 13:57:20 +0200
committerUdo Walter2017-09-13 13:57:20 +0200
commit20dae626debac91f737473175b372c27b931f283 (patch)
treec7e3c2516cf1f24c5099da1b413558d8890639e2 /modules-available/js_stupidtable
parent[exams] small design changes (diff)
downloadslx-admin-20dae626debac91f737473175b372c27b931f283.tar.gz
slx-admin-20dae626debac91f737473175b372c27b931f283.tar.xz
slx-admin-20dae626debac91f737473175b372c27b931f283.zip
[js_stupidtable] fixed stupidtable not working with collapsed tables
Diffstat (limited to 'modules-available/js_stupidtable')
-rw-r--r--modules-available/js_stupidtable/clientscript.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/modules-available/js_stupidtable/clientscript.js b/modules-available/js_stupidtable/clientscript.js
index 4e0dd4c9..8b8fc107 100644
--- a/modules-available/js_stupidtable/clientscript.js
+++ b/modules-available/js_stupidtable/clientscript.js
@@ -97,7 +97,8 @@
var column = [];
var sortFns = $table.data('sortFns');
var sortMethod = sortFns[datatype];
- var trs = $table.children("tbody").children("tr");
+ var collapsedCount = $table.children("tbody").children("tr.collapse").length;
+ var trs = $table.children("tbody").children("tr:not(.slx-decollapse)");
// Extract the data for the column that needs to be sorted and pair it up
// with the TR itself into a tuple. This way sorting the values will
@@ -124,7 +125,19 @@
// Replace the content of tbody with the sorted rows. Strangely
// enough, .append accomplishes this for us.
trs = $.map(column, function(kv) { return kv[1]; });
- $table.children("tbody").append(trs);
+
+ if (collapsedCount > 0) {
+ var showCount = trs.length - collapsedCount;
+ for (var i = 0; i < trs.length; i++) {
+ if (i < showCount) {
+ $(trs[i]).removeClass("collapse");
+ } else {
+ $(trs[i]).addClass("collapse");
+ }
+ }
+ }
+
+ $table.children("tbody").prepend(trs);
// Reset siblings
$table.find("th").data("sort-dir", null).removeClass("sorting-desc sorting-asc");