Module: check_mk
Branch: master
Commit: 540e8796aa83dd3164174595b270ed4e895ee8a5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=540e8796aa83dd…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Sep 6 18:30:06 2011 +0200
Row selection in table works now
---
web/htdocs/js/check_mk.js | 15 +++++++++++----
web/plugins/views/layouts.py | 2 +-
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/web/htdocs/js/check_mk.js b/web/htdocs/js/check_mk.js
index 4a050ac..046d61f 100644
--- a/web/htdocs/js/check_mk.js
+++ b/web/htdocs/js/check_mk.js
@@ -1061,6 +1061,15 @@ function remove_selected_rows(row_num) {
}
}
+function toggle_box(e, elem) {
+ var row_pos = g_selected_rows.indexOf(elem.name);
+ if(row_pos > -1) {
+ g_selected_rows.splice(row_pos, 1);
+ } else {
+ g_selected_rows.push(elem.name);
+ }
+}
+
function toggle_row(e, elem) {
if(!e)
e = window.event;
@@ -1089,12 +1098,10 @@ function toggle_row(e, elem) {
// Yes: Unselect it
checkbox.checked = false;
g_selected_rows.splice(row_pos, 1);
- alert('x');
} else {
// No: Select it
checkbox.checked = true;
g_selected_rows.push(checkbox.name);
- alert('x');
}
if(e.stopPropagation)
@@ -1186,8 +1193,8 @@ function table_init_rowselect(oTable) {
else
childs[i].checked = false;
- childs[i].onclick = function(e) {
- return toggle_row(e, this);
+ childs[i].onchange = function(e) {
+ toggle_box(e, this);
};
iter_cells(childs[i], function(elem) {
diff --git a/web/plugins/views/layouts.py b/web/plugins/views/layouts.py
index db0fdef..73b07f4 100644
--- a/web/plugins/views/layouts.py
+++ b/web/plugins/views/layouts.py
@@ -34,7 +34,7 @@ def render_checkbox(view, row, num_tds):
# value contains the number of columns of this datarow. This is
# needed for hiliting the correct number of TDs
html.write("<input type=checkbox name=\"%s\" value=%d />"
%
- (row_id(view, row), num_tds + 1))
+ (row_id(view, row), num_tds + 1))
def render_checkbox_td(view, row, num_tds):
html.write("<td class=checkbox>")