Failed attemt to override setCellValue. Still no visible action. setCellValue
authorW. Trevor King <wking@drexel.edu>
Sun, 18 Jul 2010 04:58:15 +0000 (00:58 -0400)
committerW. Trevor King <wking@drexel.edu>
Sun, 18 Jul 2010 04:58:15 +0000 (00:58 -0400)
static/dirtag.js

index b6f5373e93884ec745e3260cb64ecfc0628edb1b..7ad22c28f0c7c1401b6b25ae0917e4a6512b8140 100644 (file)
@@ -38,12 +38,23 @@ function tag_in_tags(tag, tags) {
 
 function setup_checkboxes(tags) {
     var tree = document.getElementById('checkbox-tree');
-    var ctags = tree.columns.getLastColumn();
+    var check = tree.columns.getFirstColumn();
+    var name = tree.columns.getPrimaryColumn();
+    tree.view.setCellText(1,name,'Johnny');
+    var v = 'false';
     for (var row=0; row<tree.view.rowCount; row++) {
-       p = tree_path(tree, row);
-       tree.view.origSetCellValue(row, ctags, tag_in_tags(p, tags));
+       var p = tree_path(tree, row);
+       if (tag_in_tags(p, tags)) {
+           v = 'true';
+       } else {
+           v = 'false';
+       }
+       tree.view.nonHookedSetCellValue(row, check, v);
+       //alert([p, tags, tag_in_tags(p, tags), tree.view.getCellValue(row, ctags)].join());
     }
-    tree.treeBoxObject.invalidateColumn(ctags);
+    tree.treeBoxObject.invalidateColumn(check);
+    tree.builder.rebuild();
+    alert('cbxs,'+tree.view.rowCount+','+tree.view.getCellValue(1,check));
 }
 
 /* Functions driving the CherryPy backend */
@@ -92,18 +103,38 @@ function remove_tag(path, tag) {
 /* The bindings themselves */
 
 function initialize() {
+    alert('hi');
     document.getElementById('element').file_path = 'UNDEFINED';
     var tree = document.getElementById('checkbox-tree');
     tree.view.origSetCellValue = tree.view.setCellValue;
-    tree.view.setCellValue = function (row, col, value) {
+    tree.view.origGetCellValue = tree.view.getCellValue;
+    tree.view.checkbox_data = new Array();
+    tree.view.nonHookedSetCellValue = function (row, col, value) {
        tree.view.origSetCellValue(row, col, value);
+       tree.view.checkbox_data[row] = value;
+       //alert('set: '+[row, col, value].join());
+    };
+    tree.view.setCellValue = function (row, col, value) {
+       tree.view.nonHookedSetCellValue(row, col, value);
        checkbox_activity(tree, row, col, value);
     };
+    tree.view.getCellValue = function (row, col) {
+       return 'true';
+       var v;
+       if (row in tree.view.checkbox_data) {
+           v = tree.view.checkbox_data[row];
+       } else {
+           v = tree.view.origGetCellValue(row, col);
+       }
+       alert('get: '+[row, col, v].join());
+       return v;
+    }
 }
 
 function new_tag_button() {
     var text = document.getElementById('new-tag-text').value;
-    new_tag(text.split('/'));
+    setup_checkboxes([['q']]);
+    //new_tag(text.split('/'));
 }
 
 function set_selected_element(path, tags, id) {