KMAIN-905 - Client speed impacted by error when viewing patron 'grid' displays
authorBill Erickson <berickxx@gmail.com>
Wed, 29 Oct 2014 21:09:42 +0000 (17:09 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
    Cross-port: b58ebe2

Open-ILS/xul/staff_client/chrome/content/util/list.js

index e7666a9..b6368c6 100644 (file)
@@ -135,17 +135,18 @@ util.list.prototype = {
                         treecol,
                         'click',
                         function(ev) {
-
-                            var toggle = ev.target.getAttribute('toggleAll') || 'on';
-                            if (toggle == 'off') toggle = 'on'; else toggle = 'off';
-                            ev.target.setAttribute('toggleAll',toggle);
-                            obj._toggle_checkbox_column(ev.target,toggle);
+                            //setTimeout(
+                                //function() {
+                                                       var toggle = ev.target.getAttribute('toggleAll') || 'on';
+                                                       if (toggle == 'off') toggle = 'on'; else toggle = 'off';
+                                                       ev.target.setAttribute('toggleAll',toggle);
+                                                       obj._toggle_checkbox_column(ev.target,toggle);
+                                //}, 0
+                            //);
                         },
                         false
                     );
-                }
-
-                else {
+                } else {
                     obj.event_listeners.add(
                         treecol,
                         'sort_first_asc',
@@ -264,15 +265,13 @@ util.list.prototype = {
                                 );
 
                                 if (r) {
-
-                                    do_it();
+                                    //setTimeout( 
+                                    do_it();//, 0 );
                                 }
 
-                            }
-
-                            else {
-
-                                do_it();
+                            } else {
+                                    //setTimeout( 
+                                    do_it();//, 0 );
                             }
 
                         },
@@ -325,15 +324,6 @@ util.list.prototype = {
                 false
             );
         }
-
-        /*
-        obj.event_listeners.add(
-            this.node,
-            'mousemove',
-            function(ev) { obj.detect_visible(); },
-            false
-        );
-        */
         obj.event_listeners.add(
             this.node,
             'keypress',
@@ -354,17 +344,6 @@ util.list.prototype = {
         );
         /* FIXME -- find events on scrollbar to trigger this */
         obj.detect_visible_polling();    
-        /*
-        var scrollbar = document.getAnonymousNodes( document.getAnonymousNodes(this.node)[1] )[1];
-        var slider = document.getAnonymousNodes( scrollbar )[2];
-        alert('scrollbar = ' + scrollbar.nodeName + ' grippy = ' + slider.nodeName);
-        scrollbar.addEventListener('click',function(){alert('sb click');},false);
-        scrollbar.addEventListener('command',function(){alert('sb command');},false);
-        scrollbar.addEventListener('scroll',function(){alert('sb scroll');},false);
-        slider.addEventListener('click',function(){alert('slider click');},false);
-        slider.addEventListener('command',function(){alert('slider command');},false);
-        slider.addEventListener('scroll',function(){alert('slider scroll');},false);
-        */
         obj.event_listeners.add(this.node, 'scroll',function(){ obj.auto_retrieve(); },false);
 
         this.restores_columns(params);
@@ -519,99 +498,71 @@ util.list.prototype = {
         this.error.sdump('D_LIST','Clearing list ' + this.node.getAttribute('id') + '\n');
         this.row_count.total = 0;
         this.row_count.fleshed = 0;
-        obj.exec_on_all_fleshed();
+        //setTimeout( function() { 
+               obj.exec_on_all_fleshed();// }, 0 );
     },
 
     '_clear_tree' : function(params) {
-
         var obj = this;
-
         if (obj.error.sdump_levels.D_LIST_DUMP_ON_CLEAR) {
-
             obj.error.sdump('D_LIST_DUMP_ON_CLEAR',obj.dump());
         }
-
         if (obj.error.sdump_levels.D_LIST_DUMP_WITH_KEYS_ON_CLEAR) {
-
             obj.error.sdump('D_LIST_DUMP_WITH_KEYS_ON_CLEAR',obj.dump_with_keys());
         }
-
         while (obj.treechildren.lastChild) obj.treechildren.removeChild( obj.treechildren.lastChild );
     },
 
     '_clear_listbox' : function(params) {
-
         var obj = this;
         var items = [];
         var nl = this.node.getElementsByTagName('listitem');
-
         for (var i = 0; i < nl.length; i++) {
-
             items.push( nl[i] );
         }
-
         for (var i = 0; i < items.length; i++) {
-
             this.node.removeChild(items[i]);
         }
     },
 
     'append' : function (params) {
-
         var rnode;
         var obj = this;
-
         switch (this.node.nodeName) {
-
             case 'tree' : rparams = this._append_to_tree(params); break;
             case 'listbox' : rparams = this._append_to_listbox(params); break;
             default: throw('NYI: Need .append() for ' + this.node.nodeName); break;
         }
-
         if (rparams && params.attributes) {
-
             for (var i in params.attributes) {
-
                 rparams.treeitem_node.setAttribute(i,params.attributes[i]);
             }
         }
         this.row_count.total++;
-
         if (this.row_count.fleshed == this.row_count.total) {
 
-            obj.exec_on_all_fleshed();
+                       obj.exec_on_all_fleshed();
         }
-
         rparams.treeitem_node.setAttribute('unique_row_counter',obj.unique_row_counter);
         rparams.unique_row_counter = obj.unique_row_counter++;
-
         if (typeof params.on_append == 'function') {
-
             params.on_append(rparams);
         }
-
         return rparams;
     },
     
     'refresh_row' : function (params) {
-
         var rnode;
         var obj = this;
-
         switch (this.node.nodeName) {
-
             case 'tree' : rparams = this._refresh_row_in_tree(params); break;
             default: throw('NYI: Need .refresh_row() for ' + this.node.nodeName); break;
         }
-
         if (rparams && params.attributes) {
-
             for (var i in params.attributes) {
-
                 rparams.treeitem_node.setAttribute(i,params.attributes[i]);
             }
         }
-
         this.row_count.fleshed--;
         return rparams;
     },
@@ -628,16 +579,10 @@ util.list.prototype = {
         var treechildren_node = this.treechildren;
 
         if (params.node && params.node.nodeName == 'treeitem') {
-
             params.node.setAttribute('container','true'); /* params.node.setAttribute('open','true'); */
-
             if (params.node.lastChild.nodeName == 'treechildren') {
-
                 treechildren_node = params.node.lastChild;
-            }
-
-            else {
-
+            } else {
                 treechildren_node = document.createElement('treechildren');
                 params.node.appendChild(treechildren_node);
             }
@@ -645,81 +590,47 @@ util.list.prototype = {
 
         var treeitem = document.createElement('treeitem');
         treeitem.setAttribute('retrieve_id',params.retrieve_id);
-
+        
         if (typeof params.to_bottom != 'undefined') {
 
             treechildren_node.appendChild( treeitem );
-
+            
             if (typeof params.no_auto_select == 'undefined') {
-
+                               
                 if (!obj.auto_select_pending) {
-
+                                       
                     obj.auto_select_pending = true;
-                    dump('auto-selecting\n');
-                    var idx = Number(obj.node.view.rowCount)-1;
-                    try { obj.node.view.selection.select(idx); } catch(E) { obj.error.sdump('D_WARN','tree auto select: ' + E + '\n'); }
-                    try { if (typeof params.on_select == 'function') params.on_select(); } catch(E) { obj.error.sdump('D_WARN','tree auto select, on_select: ' + E + '\n'); }
-                    obj.auto_select_pending = false;
-                    try { util.widgets.dispatch('flesh',obj.node.contentView.getItemAtIndex(idx).firstChild); } catch(E) { obj.error.sdump('D_WARN','tree auto select, flesh: ' + E + '\n'); }
 
+                                       dump('auto-selecting\n');
+                                       var idx = Number(obj.node.view.rowCount)-1;
+                                       try { obj.node.view.selection.select(idx); } catch(E) { obj.error.sdump('D_WARN','tree auto select: ' + E + '\n'); }
+                                       try { if (typeof params.on_select == 'function') params.on_select(); } catch(E) { obj.error.sdump('D_WARN','tree auto select, on_select: ' + E + '\n'); }
+                                       obj.auto_select_pending = false;
+                                       try { util.widgets.dispatch('flesh',obj.node.contentView.getItemAtIndex(idx).firstChild); } catch(E) { obj.error.sdump('D_WARN','tree auto select, flesh: ' + E + '\n'); }
                 }
             }
-        }
-
-        else {
+        } else {
 
             if (!params.add_before || params.add_before == null) {
             
                 if (treechildren_node.firstChild) {
 
                     treechildren_node.insertBefore( treeitem, treechildren_node.firstChild );
-                }
-
-                else {
 
+                } else {
                     treechildren_node.appendChild( treeitem );
                 }
-
                 if (typeof params.no_auto_select == 'undefined') {
-
                     if (!obj.auto_select_pending) {
 
                         obj.auto_select_pending = true;
-
-                        try {
-
-                            obj.node.view.selection.select(0);
-                        }
-
-                        catch(E) {
-
-                            obj.error.sdump('D_WARN','tree auto select: ' + E + '\n');
-                        }
-
-                        try {
-
-                            if (typeof params.on_select == 'function'){
-
-                                params.on_select();
-                            }
-                        }
-
-                        catch(E) {
-
-                            obj.error.sdump('D_WARN','tree auto select, on_select: ' + E + '\n');
-                        }
-
+                        try { obj.node.view.selection.select(0); }
+                        catch(E) { obj.error.sdump('D_WARN','tree auto select: ' + E + '\n'); }
+                        try { if (typeof params.on_select == 'function') params.on_select(); }
+                        catch(E) { obj.error.sdump('D_WARN','tree auto select, on_select: ' + E + '\n'); }
                         obj.auto_select_pending = false;
-
-                        try {
-
-                            util.widgets.dispatch('flesh',obj.node.contentView.getItemAtIndex(0).firstChild);
-                        }
-
-                        catch(E) {
-
-                            obj.error.sdump('D_WARN','tree auto select, flesh: ' + E + '\n');
-                        }
+                        try { util.widgets.dispatch('flesh',obj.node.contentView.getItemAtIndex(0).firstChild); }
+                        catch(E) { obj.error.sdump('D_WARN','tree auto select, flesh: ' + E + '\n'); }
                     }
                 }
             }
@@ -729,7 +640,6 @@ util.list.prototype = {
                 treechildren_node.insertBefore( treeitem, params.add_before );
             }
         }
-
         var treerow = document.createElement('treerow');
         treeitem.appendChild( treerow );
         treerow.setAttribute('retrieve_id',params.retrieve_id);
@@ -738,8 +648,6 @@ util.list.prototype = {
         s += ('tree = ' + this.node + '  treechildren = ' + treechildren_node + '\n');
         s += ('treeitem = ' + treeitem + '  treerow = ' + treerow + '\n');
 
-        obj.put_retrieving_label(treerow);
-
         if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
             obj.event_listeners.add(
                 treerow,
@@ -751,40 +659,31 @@ util.list.prototype = {
                     treerow.setAttribute('retrieved','true');
 
                     function inc_fleshed() {
-
                         if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
-
                         treerow.setAttribute('fleshed','true');
                         obj.row_count.fleshed++;
-
                         if (obj.row_count.fleshed >= obj.row_count.total) {
 
-                            obj.exec_on_all_fleshed();
+                                                       obj.exec_on_all_fleshed();
+
                         }
                     }
 
                     params.treeitem_node = treeitem;
                     params.on_retrieve = function(p) {
-
                         try {
-
                             p.row = params.row;
                             obj._map_row_to_treecell(p,treerow);
                             inc_fleshed();
                             var idx = obj.node.contentView.getIndexOfItem( params.treeitem_node );
                             dump('idx = ' + idx + '\n');
-
                             // if current row is selected, send another select event to re-sync data that the client code fetches on selects
                             if ( obj.node.view.selection.isSelected( idx ) ) {
-
                                 dump('dispatching select event for on_retrieve for idx = ' + idx + '\n');
                                 util.widgets.dispatch('select',obj.node);
                             }
-                        }
+                        } catch(E) {
 
-                        catch(E) {
-
-                            // Let's not alert on this for now.  Getting contentView has no properties in record buckets under certain conditions
                             dump('fixme2: ' + E + '\n');
                         }
                     }
@@ -792,28 +691,23 @@ util.list.prototype = {
                     if (typeof params.retrieve_row == 'function') {
 
                         params.retrieve_row( params );
-                    }
 
-                    else if (typeof obj.retrieve_row == 'function') {
+                    else if (typeof obj.retrieve_row == 'function') {
 
                         obj.retrieve_row( params );
-                    }
 
-                    else {
-                    
+                    else {
+
                         inc_fleshed();
                     }
-
                     obj.refresh_ordinals();
                 },
                 false
             );
-
             if (typeof params.flesh_immediately != 'undefined') {
-
                 if (params.flesh_immediately) {
 
-                    util.widgets.dispatch('flesh',treerow);
+                                       util.widgets.dispatch('flesh',treerow);
                 }
             }
         } else {
@@ -823,66 +717,46 @@ util.list.prototype = {
                 function() {
 
                     if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
-
                     obj._map_row_to_treecell(params,treerow);
                     treerow.setAttribute('retrieved','true');
                     treerow.setAttribute('fleshed','true');
                     obj.row_count.fleshed++;
-
                     if (obj.row_count.fleshed >= obj.row_count.total) {
 
-                        obj.exec_on_all_fleshed();
+                                               obj.exec_on_all_fleshed();
                     }
-
                     obj.refresh_ordinals();
                 },
-
                 false
             );
-
+            
             if (typeof params.flesh_immediately != 'undefined') {
-
+                               
                 if (params.flesh_immediately) {
 
-                    util.widgets.dispatch('flesh',treerow);
+                                       util.widgets.dispatch('flesh',treerow);
                 }
             }
         }
-
         this.error.sdump('D_LIST',s);
 
-            try {
-
-                if (obj.trim_list && obj.row_count.total >= obj.trim_list) {
-
-                    // Remove oldest row
-                    //if (typeof params.to_bottom != 'undefined') 
-                    if (typeof params.to_top == 'undefined') {
-
-                        if (typeof params.on_delete == 'function') {
-
-                            params.on_delete( treechildren_node.firstChild.getAttribute('unique_row_counter') );
-                        }
-
-                        treechildren_node.removeChild( treechildren_node.firstChild );
-                    }
-
-                    else {
+        try {
 
-                        if (typeof params.on_delete == 'function') {
+            if (obj.trim_list && obj.row_count.total >= obj.trim_list) {
 
-                            params.on_delete( treechildren_node.lastChild.getAttribute('unique_row_counter') );
-                        }
-
-                        treechildren_node.removeChild( treechildren_node.lastChild );
-                    }
+                if (typeof params.to_top == 'undefined') {
+                    if (typeof params.on_delete == 'function') { params.on_delete( treechildren_node.firstChild.getAttribute('unique_row_counter') ); }
+                    treechildren_node.removeChild( treechildren_node.firstChild );
+                } else {
+                    if (typeof params.on_delete == 'function') { params.on_delete( treechildren_node.lastChild.getAttribute('unique_row_counter') ); }
+                    treechildren_node.removeChild( treechildren_node.lastChild );
                 }
             }
+        } catch(E) {
+        }
 
-            catch(E) {
-            }
-
-        obj.auto_retrieve(); obj.refresh_ordinals();
+               obj.auto_retrieve(); 
+               obj.refresh_ordinals();
 
         params.treeitem_node = treeitem;
         return params;
@@ -900,69 +774,32 @@ util.list.prototype = {
 
         var treeitem = params.treeitem_node;
         treeitem.setAttribute('retrieve_id',params.retrieve_id);
-
         if (typeof params.to_bottom != 'undefined') {
-
             if (typeof params.no_auto_select == 'undefined') {
-
                 if (!obj.auto_select_pending) {
-
                     obj.auto_select_pending = true;
-                    var idx = Number(obj.node.view.rowCount)-1;
-
-                    try {
-
-                        obj.node.view.selection.select(idx);
-                    }
-
-                    catch(E) {
-
-                        obj.error.sdump('D_WARN','tree auto select: ' + E + '\n');
-                    }
-
-                    try {
-
-                        if (typeof params.on_select == 'function'){
-
-                            params.on_select();
-                        }
-                    }
-
-                    catch(E) {
-
-                        obj.error.sdump('D_WARN','tree auto select, on_select: ' + E + '\n');
-                    }
-
-                    obj.auto_select_pending = false;
-
-                    try {
-
-                        util.widgets.dispatch('flesh',obj.node.contentView.getItemAtIndex(idx).firstChild);
-                    }
-
-                    catch(E) {
-
-                        obj.error.sdump('D_WARN','tree auto select, flesh: ' + E + '\n');
-                    }
+                    //setTimeout(function() {
+                                       dump('auto-selecting\n');
+                                       var idx = Number(obj.node.view.rowCount)-1;
+                                       try { obj.node.view.selection.select(idx); } catch(E) { obj.error.sdump('D_WARN','tree auto select: ' + E + '\n'); }
+                                       try { if (typeof params.on_select == 'function') params.on_select(); } catch(E) { obj.error.sdump('D_WARN','tree auto select, on_select: ' + E + '\n'); }
+                                       obj.auto_select_pending = false;
+                                       try { util.widgets.dispatch('flesh',obj.node.contentView.getItemAtIndex(idx).firstChild); } catch(E) { obj.error.sdump('D_WARN','tree auto select, flesh: ' + E + '\n'); }
+                    //}, 1000);
                 }
             }
         }
-
+        //var delete_me = [];
+        //for (var i in treeitem.childNodes) if (treeitem.childNodes[i].nodeName == 'treerow') delete_me.push(treeitem.childNodes[i]);
+        //for (var i = 0; i < delete_me.length; i++) treeitem.removeChild(delete_me[i]);
         var prev_treerow = treeitem.firstChild; /* FIXME: worry about hierarchal lists like copy_browser? */
         var treerow = document.createElement('treerow');
-
         while (prev_treerow.firstChild) {
-
             treerow.appendChild( prev_treerow.removeChild( prev_treerow.firstChild ) );
         }
-
         treeitem.replaceChild( treerow, prev_treerow );
         treerow.setAttribute('retrieve_id',params.retrieve_id);
-
-        if (params.row_properties){
-
-            treerow.setAttribute('properties',params.row_properties);
-        }
+        if (params.row_properties) treerow.setAttribute('properties',params.row_properties);
 
         s += ('tree = ' + this.node.nodeName + '\n');
         s += ('treeitem = ' + treeitem.nodeName + '  treerow = ' + treerow.nodeName + '\n');
@@ -986,35 +823,26 @@ util.list.prototype = {
                         if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
                         treerow.setAttribute('fleshed','true');
                         obj.row_count.fleshed++;
-
                         if (obj.row_count.fleshed >= obj.row_count.total) {
 
-                            obj.exec_on_all_fleshed();
+                                                       obj.exec_on_all_fleshed();
                         }
                     }
 
                     params.treeitem_node = treeitem;
-
                     params.on_retrieve = function(p) {
-
                         try {
-
                             p.row = params.row;
                             obj._map_row_to_treecell(p,treerow);
                             inc_fleshed();
                             var idx = obj.node.contentView.getIndexOfItem( params.treeitem_node );
                             dump('idx = ' + idx + '\n');
-
                             // if current row is selected, send another select event to re-sync data that the client code fetches on selects
                             if ( obj.node.view.selection.isSelected( idx ) ) {
-
                                 dump('dispatching select event for on_retrieve for idx = ' + idx + '\n');
                                 util.widgets.dispatch('select',obj.node);
                             }
-                        }
-
-                        catch(E) {
-
+                        } catch(E) {
                             // Let's not alert on this for now.  Getting contentView has no properties in record buckets under certain conditions
                             dump('fixme2: ' + E + '\n');
                         }
@@ -1032,14 +860,11 @@ util.list.prototype = {
                     
                         inc_fleshed();
                     }
-
                     obj.refresh_ordinals();
                 },
                 false
             );
-
             if (typeof params.flesh_immediately != 'undefined') {
-
                 if (params.flesh_immediately) {
 
                     util.widgets.dispatch('flesh',treerow);
@@ -1056,24 +881,19 @@ util.list.prototype = {
                 function() {
 
                     if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
-
                     obj._map_row_to_treecell(params,treerow);
                     treerow.setAttribute('retrieved','true');
                     treerow.setAttribute('fleshed','true');
                     obj.row_count.fleshed++;
-
                     if (obj.row_count.fleshed >= obj.row_count.total) {
 
-                        obj.exec_on_all_fleshed();
+                                               obj.exec_on_all_fleshed();
                     }
-
                     obj.refresh_ordinals();
                 },
                 false
             );
-
             if (typeof params.flesh_immediately != 'undefined') {
-
                 if (params.flesh_immediately) {
 
                     util.widgets.dispatch('flesh',treerow);
@@ -1082,29 +902,21 @@ util.list.prototype = {
 
         }
 
-            try {
-
-                if (obj.trim_list && obj.row_count.total >= obj.trim_list) {
-
-                    // Remove oldest row
-                    //if (typeof params.to_bottom != 'undefined') 
-                    if (typeof params.to_top == 'undefined') {
-
-                        treechildren_node.removeChild( treechildren_node.firstChild );
-                    }
-
-                    else {
+        try {
 
-                        treechildren_node.removeChild( treechildren_node.lastChild );
-                    }
+            if (obj.trim_list && obj.row_count.total >= obj.trim_list) {
+                // Remove oldest row
+                if (typeof params.to_top == 'undefined') {
+                    treechildren_node.removeChild( treechildren_node.firstChild );
+                } else {
+                    treechildren_node.removeChild( treechildren_node.lastChild );
                 }
             }
+        } catch(E) {
+        }
 
-            catch(E) {
-            }
-
-        obj.auto_retrieve();
-        obj.refresh_ordinals();
+               obj.auto_retrieve(); 
+               obj.refresh_ordinals();
 
         JSAN.use('util.widgets'); util.widgets.dispatch('select',obj.node);
 
@@ -1114,51 +926,36 @@ util.list.prototype = {
     },
 
     'refresh_ordinals' : function() {
-
         var obj = this;
-
         try {
-
             if (obj.refresh_ordinals_timeout_id) { return; }
 
             function _refresh_ordinals(clear) {
-
                 var nl = obj.node.getElementsByAttribute('label','_');
-
                 for (var i = 0; i < nl.length; i++) {
-
                     nl[i].setAttribute(
                         'ord_col',
                         'true'
                     );
-
                     nl[i].setAttribute( // treecell properties for css styling
                         'properties',
                         'ordinal'
                     );
                 }
-
                 nl = obj.node.getElementsByAttribute('ord_col','true');
-
                 for (var i = 0; i < nl.length; i++) {
-
                     nl[i].setAttribute(
                         'label',
                         // we could just use 'i' here if we trust the order of elements
                         1 + obj.node.contentView.getIndexOfItem(nl[i].parentNode.parentNode) // treeitem
                     );
                 }
-
-                if (clear) {
-
-                    obj.refresh_ordinals_timeout_id = null;
-                }
+                if (clear) { obj.refresh_ordinals_timeout_id = null; }
             }
 
             // spamming this to cover race conditions
             setTimeout(_refresh_ordinals, 500); // for speedy looking UI updates
             setTimeout(_refresh_ordinals, 2000); // for most uses
-
             obj.refresh_ordinals_timeout_id = setTimeout(
                 function() {
                     _refresh_ordinals(true);
@@ -1166,274 +963,173 @@ util.list.prototype = {
                 4000 // just in case, say with a slow rendering list
             );
 
-        }
-
-        catch(E) {
-
+        } catch(E) {
             alert('Error in list.js, refresh_ordinals(): ' + E);
         }
     },
 
     'put_retrieving_label' : function(treerow) {
-
         var obj = this;
-
         try {
-
             for (var i = 0; i < obj.columns.length; i++) {
-
                 var treecell;
-
                 if (typeof treerow.childNodes[i] == 'undefined') {
-
                     treecell = document.createElement('treecell');
                     treerow.appendChild(treecell);
-                }
-
-                else {
-
+                } else {
                     treecell = treerow.childNodes[i];
                 }
-
                 treecell.setAttribute('label',document.getElementById('offlineStrings').getString('list.row_retrieving'));
             }
-        }
-
-        catch(E) {
+        } catch(E) {
             alert('Error in list.js, put_retrieving_label(): ' + E);
         }
     },
 
     'detect_visible' : function() {
-
         var obj = this;
-
         try {
-
+            //dump('detect_visible  obj.node = ' + obj.node + '\n');
             /* FIXME - this is a hack.. if the implementation of tree changes, this could break */
             try {
-
+                /*var s = ''; var A = document.getAnonymousNodes(obj.node);
+                for (var i in A) {
+                    var B = A[i];
+                    s += '\t' + (typeof B.nodeName != 'undefined' ? B.nodeName : B ) + '\n'; 
+                    if (typeof B.childNodes != 'undefined') for (var j = 0; j < B.childNodes.length; j++) {
+                        var C = B.childNodes[j];
+                        s += '\t\t' + C.nodeName + '\n';
+                    }
+                }
+                obj.error.sdump('D_XULRUNNER','document.getAnonymousNodes(' + obj.node.nodeName + ') = \n' + s + '\n');*/
                 var scrollbar = document.getAnonymousNodes(obj.node)[2].firstChild;
                 var curpos = scrollbar.getAttribute('curpos');
                 var maxpos = scrollbar.getAttribute('maxpos');
-
+                //alert('curpos = ' + curpos + ' maxpos = ' + maxpos + ' obj.curpos = ' + obj.curpos + ' obj.maxpos = ' + obj.maxpos + '\n');
                 if ((curpos != obj.curpos) || (maxpos != obj.maxpos)) {
-
                     if ( obj.auto_retrieve() > 0 ) {
-
                         obj.curpos = curpos; obj.maxpos = maxpos;
                     }
                 }
-            }
-
-            catch(E) {
-
+            } catch(E) {
                 obj.error.sdump('D_XULRUNNER', 'List implementation changed? ' + E);
             }
-        }
-
-        catch(E) {
-
-            obj.error.sdump('D_ERROR',E);
-        }
+        } catch(E) { obj.error.sdump('D_ERROR',E); }
     },
 
     'detect_visible_polling' : function() {
-
         try {
-
+            //alert('detect_visible_polling');
             var obj = this;
             obj.detect_visible();
-            setTimeout(function() {
-
-                try {
-
-                    obj.detect_visible_polling();
-                }
-
-                catch(E) {
-
-                    alert(E);
-                }
-            }, 2000);
-        }
-
-        catch(E) {
-
+            setTimeout(function() { try { obj.detect_visible_polling(); } catch(E) { alert(E); } },2000);
+        } catch(E) {
             alert(E);
         }
     },
 
-    'auto_retrieve' : function(params) {
 
+    'auto_retrieve' : function(params) {
         var obj = this;
-
         switch (this.node.nodeName) {
-
             case 'tree' : obj._auto_retrieve_tree(params); break;
             default: throw('NYI: Need .auto_retrieve() for ' + obj.node.nodeName); break;
         }
     },
 
-    '_auto_retrieve_tree' : function (params) {
-
-        var obj = this;
-
-        if (!obj.auto_retrieve_in_progress) {
-
-            obj.auto_retrieve_in_progress = true;
-            setTimeout(
-                function() {
-                    try {
-
-                        var count = 0;
-                        var startpos = obj.node.treeBoxObject.getFirstVisibleRow();
-                        var endpos = obj.node.treeBoxObject.getLastVisibleRow();
-                        if (startpos > endpos) endpos = obj.node.treeBoxObject.getPageLength();
-
-                        for (var i = startpos; i < endpos + 4; i++) {
-
-                            try {
-
-                                var item = obj.node.contentView.getItemAtIndex(i).firstChild;
-
-                                if (item && item.getAttribute('retrieved') != 'true' ) {
-
-                                    util.widgets.dispatch('flesh',item); count++;
-                                }
-                            }
-
-                            catch(E) {
-
-                                dump(i + ' : ' + E + '\n');
-                            }
-                        }
-
-                        obj.auto_retrieve_in_progress = false;
-                        return count;
-                    }
-
-                    catch(E) {
-
-                        alert(E);
-                    }
-                }, 1
-            );
+    '_auto_retrieve_tree' : function (params) {
+        var obj = this;
+        if (!obj.auto_retrieve_in_progress) {
+            obj.auto_retrieve_in_progress = true;
+            //setTimeout(
+                //function() {
+                       try {
+                                       //alert('auto_retrieve\n');
+                                       var count = 0;
+                                       var startpos = obj.node.treeBoxObject.getFirstVisibleRow();
+                                       var endpos = obj.node.treeBoxObject.getLastVisibleRow();
+                                       if (startpos > endpos) endpos = obj.node.treeBoxObject.getPageLength();
+                                       //dump('startpos = ' + startpos + ' endpos = ' + endpos + '\n');
+                                       for (var i = startpos; i < endpos + 4; i++) {
+                                               try {
+                                                       //dump('trying index ' + i + '\n');
+                                                       var item = obj.node.contentView.getItemAtIndex(i).firstChild;
+                                                       if (item && item.getAttribute('retrieved') != 'true' ) {
+                                                               //dump('\tgot an unfleshed item = ' + item + ' = ' + item.nodeName + '\n');
+                                                               util.widgets.dispatch('flesh',item); count++;
+                                                       }
+                                               } catch(E) {
+                                                       //dump(i + ' : ' + E + '\n');
+                                               }
+                                       }
+                                       obj.auto_retrieve_in_progress = false;
+                                       return count;
+                       } catch(E) { alert(E); }
+                //}, 1
+            //);
         }
     },
 
     'exec_on_all_fleshed' : function() {
-
         var obj = this;
-
         try {
-
             if (obj.on_all_fleshed) {
-
                 if (typeof obj.on_all_fleshed == 'function') {
-
                     dump('exec_on_all_fleshed == function\n');
-
-                    try {
-
-                        obj.on_all_fleshed();
-                    }
-
-                    catch(E) {
-
-                        obj.error.standard_unexpected_error_alert('_full_retrieve_tree callback',obj.on_all_fleshed);
-                    }
-
-                }
-
-                else if (typeof obj.on_all_fleshed.length != 'undefined') {
-
+                    //setTimeout( 
+                        //function() { 
+                    try { obj.on_all_fleshed(); } catch(E) { obj.error.standard_unexpected_error_alert('_full_retrieve_tree callback',obj.on_all_fleshed); }
+                        //}, 0 
+                    //);
+                } else if (typeof obj.on_all_fleshed.length != 'undefined') {
                     dump('exec_on_all_fleshed == array\n');
-
-                    try {
-
-                        dump('exec_on_all_fleshed, processing on_all_fleshed array, length = ' + obj.on_all_fleshed.length + '\n');
-                        var f = obj.on_all_fleshed.pop();
-
-                        if (typeof f == 'function') { 
-
-                            try {
-
-                                f();
-                            }
-
-                            catch(E) {
-
-                                obj.error.standard_unexpected_error_alert('_full_retrieve_tree callback',E);
-                            }
-                        }
-
-                        if (obj.on_all_fleshed.length > 0){
-
-                            arguments.callee();
-                        }
-                    }
-
-                    catch(E) {
-
-                        obj.error.standard_unexpected_error_alert('exec_on_all_fleshed callback error',E);
-                    }
-
-                }
-
-                else {
-
+                    //setTimeout(
+                        //function() {
+                                       try {
+                                               dump('exec_on_all_fleshed, processing on_all_fleshed array, length = ' + obj.on_all_fleshed.length + '\n');
+                                               var f = obj.on_all_fleshed.pop();
+                                               if (typeof f == 'function') { 
+                                                       try { f(); } catch(E) { obj.error.standard_unexpected_error_alert('_full_retrieve_tree callback',E); }
+                                               }
+                                               if (obj.on_all_fleshed.length > 0) arguments.callee(); 
+                                       } catch(E) {
+                                               obj.error.standard_unexpected_error_alert('exec_on_all_fleshed callback error',E);
+                                       }
+                        //}, 0
+                    //); 
+                } else {
                     obj.error.standard_unexpected_error_alert('unexpected on_all_fleshed object: ', obj.on_all_fleshed);
                 }
             }
-        }
-
-        catch(E) {
-
+        } catch(E) {
             obj.error.standard_unexpected_error_alert('exec_on_all-fleshed error',E);
         }
     },
 
     'full_retrieve' : function(params) {
-
         var obj = this;
-
         switch (this.node.nodeName) {
-
             case 'tree' : obj._full_retrieve_tree(params); break;
             default: throw('NYI: Need .full_retrieve() for ' + obj.node.nodeName); break;
         }
-
         obj.refresh_ordinals();
     },
 
     '_full_retrieve_tree' : function(params) {
-
         var obj = this;
-
         try {
-
             if (obj.row_count.fleshed >= obj.row_count.total) {
-
                 dump('Full retrieve... tree seems to be in sync\n' + js2JSON(obj.row_count) + '\n');
                 obj.exec_on_all_fleshed();
-            }
-
-            else {
-
+            } else {
                 dump('Full retrieve... syncing tree' + js2JSON(obj.row_count) + '\n');
                 JSAN.use('util.widgets');
                 var nodes = obj.treechildren.childNodes;
-
                 for (var i = 0; i < nodes.length; i++) {
-
                     util.widgets.dispatch('flesh',nodes[i].firstChild);
                 }
             }
-        }
-
-        catch(E) {
-
+        } catch(E) {
             obj.error.standard_unexpected_error_alert('_full_retrieve_tree',E);
         }
     },
@@ -1452,38 +1148,35 @@ util.list.prototype = {
 
         if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
 
-            listitem.setAttribute('retrieve_id',params.retrieve_id);
-
-            //FIXME//Make async and fire when row is visible in list
-            var row;
-
-            params.treeitem_node = listitem;
-            params.on_retrieve = function(row) {
-
-                params.row = row;
-                obj._map_row_to_listcell(params,listitem);
-                obj.node.appendChild( listitem );
-                util.widgets.dispatch('select',obj.node);
-            }
-
-            if (typeof params.retrieve_row == 'function') {
-
-                row = params.retrieve_row( params );
+            //setTimeout(
+                //function() {
+                       listitem.setAttribute('retrieve_id',params.retrieve_id);
+                       //FIXME//Make async and fire when row is visible in list
+                       var row;
 
-            }
+                       params.treeitem_node = listitem;
+                       params.on_retrieve = function(row) {
+                               params.row = row;
+                               obj._map_row_to_listcell(params,listitem);
+                               obj.node.appendChild( listitem );
+                               util.widgets.dispatch('select',obj.node);
+                       }
 
-            else {
+                       if (typeof params.retrieve_row == 'function') {
 
-                if (typeof obj.retrieve_row == 'function') {
+                               row = params.retrieve_row( params );
 
-                    row = obj.retrieve_row( params );
+                       } else {
 
-                }
-            }
-        }
+                               if (typeof obj.retrieve_row == 'function') {
 
-        else {
+                                       row = obj.retrieve_row( params );
 
+                               }
+                       }
+                //}, 0
+            //);
+        } else {
             this._map_row_to_listcell(params,listitem);
             this.node.appendChild( listitem );
         }
@@ -1491,97 +1184,67 @@ util.list.prototype = {
         this.error.sdump('D_LIST',s);
         params.treeitem_node = listitem;
         return params;
+
     },
 
     '_map_row_to_treecell' : function(params,treerow) {
-
         var obj = this;
         var s = '';
 
         if (typeof params.map_row_to_column == 'function' || typeof this.map_row_to_column == 'function') {
 
             for (var i = 0; i < this.columns.length; i++) {
-
                 var treecell;
-
                 if (typeof treerow.childNodes[i] == 'undefined') {
-
                     treecell = document.createElement('treecell');
                     treerow.appendChild( treecell );
-                }
-
-                else {
-
+                } else {
                     treecell = treerow.childNodes[i];
                 }
                 
-                if ( this.columns[i].editable == false ) {
-
-                    treecell.setAttribute('editable','false');
-                }
-
+                if ( this.columns[i].editable == false ) { treecell.setAttribute('editable','false'); }
                 var label = '';
                 var sort_value = '';
 
                 // What skip columns is doing is rendering the treecells as blank/empty
                 if (params.skip_columns && (params.skip_columns.indexOf(i) != -1)) {
-
                     treecell.setAttribute('label',label);
                     s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
                     continue;
                 }
-
                 if (params.skip_all_columns_except && (params.skip_all_columns_except.indexOf(i) == -1)) {
-
                     treecell.setAttribute('label',label);
                     s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
                     continue;
                 }
     
                 if (typeof params.map_row_to_column == 'function')  {
+                   if (this.columns[i].id == 'lineno'){
 
-                    if (this.columns[i].id == 'lineno'){
-
-                      label = this.count_for_display.toString();
-                      this.count_for_display++;
-
-                    }
-
-                    else {
-            
-                      label = params.map_row_to_column(params.row,this.columns[i],this.scratch_data);
-                    }
-                }
-
-                else if (typeof this.map_row_to_column == 'function') {
-
-                    if (this.columns[i].id == 'lineno'){
-
-                      label = this.count_for_display.toString();
-                      this.count_for_display++;
-                    }
-
-                    else {
+                     label = this.count_for_display.toString();
+                     this.count_for_display++;
 
-                      label = this.map_row_to_column(params.row,this.columns[i],this.scratch_data);
-                    }
-                }
+                   } else {
+    
+                     label = params.map_row_to_column(params.row,this.columns[i],this.scratch_data);
 
-                if (this.columns[i].type == 'checkbox') {
+                   }
+                } else if (typeof this.map_row_to_column == 'function') {
+                   if (this.columns[i].id == 'lineno'){
 
-                    treecell.setAttribute('value',label);
-                }
+                     label = this.count_for_display.toString();
+                     this.count_for_display++;
 
-                else {
+                   } else {
 
-                    treecell.setAttribute('label',label ? label : '');
+                     label = this.map_row_to_column(params.row,this.columns[i],this.scratch_data);
+    
+                   }
                 }
-
+                if (this.columns[i].type == 'checkbox') { treecell.setAttribute('value',label); } else { treecell.setAttribute('label',label ? label : ''); }
                 s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
             }
-        }
-
-        else if (typeof params.map_row_to_columns == 'function' || typeof this.map_row_to_columns == 'function') {
+        } else if (typeof params.map_row_to_columns == 'function' || typeof this.map_row_to_columns == 'function') {
 
             var labels = [];
             var sort_values = [];
@@ -1589,256 +1252,173 @@ util.list.prototype = {
             if (typeof params.map_row_to_columns == 'function') {
 
                 var values = params.map_row_to_columns(params.row,this.columns,this.scratch_data);
-
                 if (typeof values.values == 'undefined') {
-
                     labels = values;
-                }
-
-                else {
-
+                } else {
                     labels = values.values;
                     sort_values = values.sort_values;
                 }
-            }
 
-            else if (typeof this.map_row_to_columns == 'function') {
+            else if (typeof this.map_row_to_columns == 'function') {
 
                 var values = this.map_row_to_columns(params.row,this.columns,this.scratch_data);
-
                 if (typeof values.values == 'undefined') {
-
                     labels = values;
-                }
-
-                else {
-
+                } else {
                     labels = values.values;
                     sort_values = values.sort_values;
                 }
             }
-
             for (var i = 0; i < labels.length; i++) {
-
                 var treecell;
-
                 if (typeof treerow.childNodes[i] == 'undefined') {
-
                     treecell = document.createElement('treecell');
                     treerow.appendChild(treecell);
-                }
-
-                else {
-
+                } else {
                     treecell = treerow.childNodes[i];
                 }
-
-                if ( this.columns[i].editable == false ) {
-
-                    treecell.setAttribute('editable','false');
-                }
-
+                if ( this.columns[i].editable == false ) { treecell.setAttribute('editable','false'); }
                 if ( this.columns[i].type == 'checkbox') {
-
                     treecell.setAttribute('value', labels[i]);
-                }
-
-                else {
-
+                } else {
                     treecell.setAttribute('label',typeof labels[i] == 'string' || typeof labels[i] == 'number' ? labels[i] : '');
                 }
-
                 if (sort_values[i]) {
-
                     treecell.setAttribute('sort_value',js2JSON(sort_values[i]));
                 }
-
                 s += ('treecell = ' + treecell + ' with label = ' + labels[i] + '\n');
             }
 
-        }
-
-        else {
+        } else {
 
             throw('No row to column mapping function.');
         }
-
         this.error.sdump('D_LIST',s);
     },
 
     '_map_row_to_listcell' : function(params,listitem) {
-
         var obj = this;
         var s = '';
-
         for (var i = 0; i < this.columns.length; i++) {
-
             var value = '';
-
             if (typeof params.map_row_to_column == 'function')  {
 
                 value = params.map_row_to_column(params.row,this.columns[i],this.scratch_data);
-            }
 
-            else {
+            else {
 
                 if (typeof this.map_row_to_column == 'function') {
 
                     value = this.map_row_to_column(params.row,this.columns[i],this.scratch_data);
                 }
             }
-
             if (typeof value == 'string' || typeof value == 'number') {
-
                 var listcell = document.createElement('listcell');
                 listcell.setAttribute('label',value);
                 listitem.appendChild(listcell);
                 s += ('listcell = ' + listcell + ' with label = ' + value + '\n');
-            }
-
-            else {
-
+            } else {
                 listitem.appendChild(value);
                 s += ('listcell = ' + value + ' is really a ' + value.nodeName + '\n');
             }
         }
-
         this.error.sdump('D_LIST',s);
     },
 
     'select_all' : function(params) {
-
         var obj = this;
-
         switch(this.node.nodeName) {
-
             case 'tree' : return this._select_all_from_tree(params); break;
             default: throw('NYI: Need ._select_all_from_() for ' + this.node.nodeName); break;
         }
     },
 
     '_select_all_from_tree' : function(params) {
-
         var obj = this;
         this.node.view.selection.selectAll();
     },
 
     'retrieve_selection' : function(params) {
-
         var obj = this;
-
         switch(this.node.nodeName) {
-
             case 'tree' : return this._retrieve_selection_from_tree(params); break;
             default: throw('NYI: Need ._retrieve_selection_from_() for ' + this.node.nodeName); break;
         }
     },
 
     '_retrieve_selection_from_tree' : function(params) {
-
         var obj = this;
         var list = [];
         var start = new Object();
         var end = new Object();
         var numRanges = this.node.view.selection.getRangeCount();
-
         for (var t=0; t<numRanges; t++){
-
             this.node.view.selection.getRangeAt(t,start,end);
-
             for (var v=start.value; v<=end.value; v++){
-
                 var i = this.node.contentView.getItemAtIndex(v);
                 list.push( i );
             }
         }
-
         return list;
     },
 
     'dump' : function(params) {
-
         var obj = this;
-
         switch(this.node.nodeName) {
-
             case 'tree' : return this._dump_tree(params); break;
             default: throw('NYI: Need .dump() for ' + this.node.nodeName); break;
         }
     },
 
     '_dump_tree' : function(params) {
-
         var obj = this;
         var dump = [];
-
         for (var i = 0; i < this.treechildren.childNodes.length; i++) {
-
             var row = [];
             var treeitem = this.treechildren.childNodes[i];
             var treerow = treeitem.firstChild;
-
             for (var j = 0; j < treerow.childNodes.length; j++) {
-
                 row.push( treerow.childNodes[j].getAttribute('label') );
             }
-
             dump.push( row );
         }
-
         return dump;
     },
 
     'dump_with_keys' : function(params) {
-
         var obj = this;
-
         switch(this.node.nodeName) {
-
             case 'tree' : return this._dump_tree_with_keys(params); break;
             default: throw('NYI: Need .dump_with_keys() for ' + this.node.nodeName); break;
         }
+
     },
 
     '_dump_tree_with_keys' : function(params) {
-
         var obj = this;
         var dump = [];
 
         function process_tree(treechildren) {
-
             for (var i = 0; i < treechildren.childNodes.length; i++) {
-
                 var row = {};
                 var treeitem = treechildren.childNodes[i];
                 var treerow = treeitem.firstChild;
-
                 for (var j = 0; j < treerow.childNodes.length; j++) {
-
                     if (typeof obj.columns[j] == 'undefined') {
-
                         dump('=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n');
                         dump('_dump_tree_with_keys @ ' + location.href + '\n');
                         dump('\ttreerow.childNodes.length='+treerow.childNodes.length+' j='+j+' obj.columns.length='+obj.columns.length+'\n');
                         debugger;
-                    }
-
-                    else {
-
+                    } else {
                         row[ obj.columns[j].id ] = treerow.childNodes[j].getAttribute('label');
                         var sort = treerow.childNodes[j].getAttribute('sort_value');
-
                         if(sort) {
-
                             row[ obj.columns[j].id + '_sort_value' ] = sort;
                         }
                     }
                 }
-
                 dump.push( row );
-
                 if (treeitem.childNodes.length > 1) {
-
                     process_tree(treeitem.lastChild);
                 }
             }
@@ -1850,11 +1430,8 @@ util.list.prototype = {
     },
 
     'dump_csv' : function(params) {
-
         var obj = this;
-
         switch(this.node.nodeName) {
-
             case 'tree' : return this._dump_tree_csv(params); break;
             default: throw('NYI: Need .dump_csv() for ' + this.node.nodeName); break;
         }
@@ -1862,67 +1439,38 @@ util.list.prototype = {
     },
 
     '_dump_tree_csv' : function(params) {
-
         var obj = this;
         var _dump = '';
         var ord_cols = [];
-
         for (var j = 0; j < obj.columns.length; j++) {
-
             if (obj.node.treeBoxObject.columns.getColumnAt(j).element.getAttribute('hidden') == 'true') {
-
                 /* skip */
-            }
-
-            else {
-
+            } else {
                 ord_cols.push( [ obj.node.treeBoxObject.columns.getColumnAt(j).element.getAttribute('ordinal'), j ] );
             }
         }
-
         ord_cols.sort( function(a,b) { 
-
-            if ( Number( a[0] ) < Number( b[0] ) ) return -1;
-
-            if ( Number( a[0] ) > Number( b[0] ) ) return 1;
-
+            if ( Number( a[0] ) < Number( b[0] ) ) return -1; 
+            if ( Number( a[0] ) > Number( b[0] ) ) return 1; 
             return 0;
         } );
-
         for (var j = 0; j < ord_cols.length; j++) {
-
-            if (_dump){
-
-                _dump += ',';
-            }
-
+            if (_dump) _dump += ',';
             _dump += '"' + obj.columns[ ord_cols[j][1] ].label.replace(/"/g, '""') + '"';
         }
-
         _dump += '\r\n';
 
         function process_tree(treechildren) {
-
             for (var i = 0; i < treechildren.childNodes.length; i++) {
-
                 var row = '';
                 var treeitem = treechildren.childNodes[i];
                 var treerow = treeitem.firstChild;
-
                 for (var j = 0; j < ord_cols.length; j++) {
-
-                    if (row){
-
-                        row += ',';
-                    }
-
+                    if (row) row += ',';
                     row += '"' + treerow.childNodes[ ord_cols[j][1] ].getAttribute('label').replace(/"/g, '""') + '"';
                 }
-
                 _dump +=  row + '\r\n';
-
                 if (treeitem.childNodes.length > 1) {
-
                     process_tree(treeitem.lastChild);
                 }
             }
@@ -1934,11 +1482,8 @@ util.list.prototype = {
     },
 
     'dump_extended_format' : function(params) {
-
         var obj = this;
-
         switch(this.node.nodeName) {
-
             case 'tree' : return this._dump_tree_extended_format(params); break;
             default: throw('NYI: Need .dump_extended_format() for ' + this.node.nodeName); break;
         }
@@ -1946,26 +1491,17 @@ util.list.prototype = {
     },
 
     '_dump_tree_extended_format' : function(params) {
-
         var obj = this;
         var _dump = '';
         var ord_cols = [];
-
         for (var j = 0; j < obj.columns.length; j++) {
-
             if (obj.node.treeBoxObject.columns.getColumnAt(j).element.getAttribute('hidden') == 'true') {
-
                 /* skip */
-            }
-
-            else {
-
+            } else {
                 ord_cols.push( [ obj.node.treeBoxObject.columns.getColumnAt(j).element.getAttribute('ordinal'), j ] );
             }
         }
-
-        ord_cols.sort( function(a,b) {
+        ord_cols.sort( function(a,b) { 
             if ( Number( a[0] ) < Number( b[0] ) ) return -1; 
             if ( Number( a[0] ) > Number( b[0] ) ) return 1; 
             return 0;
@@ -2549,15 +2085,15 @@ util.list.prototype = {
                 var def = {
                     'id' : col_id,
                     'label' : my_field.label || my_field.name,
-                    'sort_type' : [ 'int', 'float', 'id', 'number' ].indexOf(my_field.datatype) > -1 ? 'number' : 
-                        ( my_field.datatype == 'money' ? 'money' : 
+                    'sort_type' : [ 'int', 'float', 'id', 'number' ].indexOf(my_field.datatype) > -1 ? 'number' :
+                        ( my_field.datatype == 'money' ? 'money' :
                         ( my_field.datatype == 'timestamp' ? 'date' : 'default')),
                     'hidden' : my_field.virtual || my_field.datatype == 'link',
                     'flex' : 1
-                };                    
+                };
                 // my_field.datatype => bool float id int interval link money number org_unit text timestamp
                 if (my_field.datatype == 'link') {
-                    def.render = function(my) { 
+                    def.render = function(my) {
                         // is the object fleshed?
                         return my[dataobj][datafield]() && typeof my[dataobj][datafield]() == 'object'
                             // yes, show the display field
@@ -2575,7 +2111,7 @@ util.list.prototype = {
                                 )
                                 // no, just show the raw value
                                 : my[dataobj][datafield]()
-                            ); 
+                            );
                     }
                 } else {
                     def.render = function(my) { return my[dataobj][datafield](); }