Allow updating the filters separately
[misc/kostenrechnung] / lib / functions.js
index f1b6d4d..2de1400 100644 (file)
@@ -66,10 +66,12 @@ function set_value(id, value)
        obj.value = value;
     else if (obj.nodeName.toLowerCase() == 'span')
        obj.innerHTML = value;
-    else if (obj.nodeName.toLowerCase() == 'select')
+    else if (obj.nodeName.toLowerCase() == 'select') {
        for (var i=0; i < obj.options.length; i++)
            if (obj.options[i].value == value)
                obj.selectedIndex = i;
+    } else
+       obj.innerHTML = value;
 }
 
 function setvar(obj, name, callback, status)
@@ -222,6 +224,25 @@ function grid_update(grid, filter, value)
     grid.buffer.fetch(-1);
 }
 
+function grid_update_filters(grid)
+{
+    var todo = false;
+    for (var c=0; c < grid.headerColCnt; c++) {
+       var fmt = grid.columns[c].format;
+       if (typeof fmt.filterUI != 'string') continue;
+       if (fmt.filterUI != 's') continue;
+       $(grid.filterId(c)).options.length = 1;
+
+       var options = {};
+       Object.extend(options, grid.buffer.ajaxOptions);
+       var colnum = typeof(fmt.filterCol)=='number' ? fmt.filterCol : c;
+
+       options.parameters = 'id='+grid.tableId+'&distinct='+colnum;
+       options.onComplete = grid.filterValuesUpdate.bind(grid,c);
+       new Ajax.Request(grid.buffer.dataSource, options);
+    }
+}
+
 var calendars = new Array();
 function calendar_callback(value)
 {