From: phasefx Date: Fri, 11 Jun 2010 20:32:43 +0000 (+0000) Subject: troubleshooting DOM issue where too many columns in a treerow X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=fc341b40e8803ad43fe380a12876a1221ac10e0d;p=evergreen%2Fbjwebb.git troubleshooting DOM issue where too many columns in a treerow some refactoring and comment cleanup. toward having the need for treecell creation be determined on a column by column basis rather than examining the contents of a treerow in one go git-svn-id: svn://svn.open-ils.org/ILS/trunk@16687 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js index d5da65ef3..47481fef4 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -461,9 +461,9 @@ util.list.prototype = { s += ('tree = ' + this.node + ' treechildren = ' + treechildren_node + '\n'); s += ('treeitem = ' + treeitem + ' treerow = ' + treerow + '\n'); - if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') { + obj.put_retrieving_label(treerow); - obj.put_retrieving_label(treerow); + if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') { treerow.addEventListener( 'flesh', function() { @@ -527,7 +527,6 @@ util.list.prototype = { } } } else { - obj.put_retrieving_label(treerow); treerow.addEventListener( 'flesh', function() { @@ -619,11 +618,12 @@ util.list.prototype = { s += ('tree = ' + this.node.nodeName + '\n'); s += ('treeitem = ' + treeitem.nodeName + ' treerow = ' + treerow.nodeName + '\n'); + obj.put_retrieving_label(treerow); + if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') { s += 'found a retrieve_row function\n'; - obj.put_retrieving_label(treerow); treerow.addEventListener( 'flesh', function() { @@ -691,7 +691,6 @@ util.list.prototype = { s += 'did not find a retrieve_row function\n'; - obj.put_retrieving_label(treerow); treerow.addEventListener( 'flesh', function() { @@ -745,29 +744,16 @@ util.list.prototype = { 'put_retrieving_label' : function(treerow) { var obj = this; try { - /* - var cols_idx = 0; - dump('put_retrieving_label. columns = ' + js2JSON(obj.columns) + '\n'); - while( obj.columns[cols_idx] && obj.columns[cols_idx].hidden && obj.columns[cols_idx].hidden == 'true') { - dump('\t' + cols_idx); - var treecell = document.createElement('treecell'); - treerow.appendChild(treecell); - cols_idx++; - } - */ - var create_treecells = treerow.childNodes.length == 0; for (var i = 0; i < obj.columns.length; i++) { - var treecell = create_treecells ? document.createElement('treecell') : treerow.childNodes[i]; - if (treecell) { - if (create_treecells) { - treecell.setAttribute('label',document.getElementById('offlineStrings').getString('list.row_retrieving')); - treerow.appendChild(treecell); - } + var treecell; + if (typeof treerow.childNodes[i] == 'undefined') { + treecell = document.createElement('treecell'); + treerow.appendChild(treecell); + } else { + treecell = treerow.childNodes[i]; } + treecell.setAttribute('label',document.getElementById('offlineStrings').getString('list.row_retrieving')); } - /* - dump('\t' + cols_idx + '\n'); - */ } catch(E) { alert('Error in list.js, put_retrieving_label(): ' + E); } @@ -976,24 +962,29 @@ util.list.prototype = { '_map_row_to_treecell' : function(params,treerow) { var obj = this; var s = ''; - //util.widgets.remove_children(treerow); - var create_treecells = treerow.childNodes.length == 0; 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 = create_treecells ? document.createElement('treecell') : treerow.childNodes[i]; + var treecell; + if (typeof treerow.childNodes[i] == 'undefined') { + treecell = document.createElement('treecell'); + treerow.appendChild( treecell ); + } else { + treecell = treerow.childNodes[i]; + } + if ( this.columns[i].editable == false ) { treecell.setAttribute('editable','false'); } var label = ''; + + // 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); - treerow.appendChild( treecell ); 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); - treerow.appendChild( treecell ); s += ('treecell = ' + treecell + ' with label = ' + label + '\n'); continue; } @@ -1008,7 +999,6 @@ util.list.prototype = { } if (this.columns[i].type == 'checkbox') { treecell.setAttribute('value',label); } else { treecell.setAttribute('label',label ? label : ''); } - if (create_treecells) { treerow.appendChild( treecell ); } s += ('treecell = ' + treecell + ' with label = ' + label + '\n'); } } else if (typeof params.map_row_to_columns == 'function' || typeof this.map_row_to_columns == 'function') { @@ -1025,14 +1015,19 @@ util.list.prototype = { } for (var i = 0; i < labels.length; i++) { - var treecell = create_treecells ? document.createElement('treecell') : treerow.childNodes[i]; + var treecell; + if (typeof treerow.childNodes[i] == 'undefined') { + treecell = document.createElement('treecell'); + treerow.appendChild(treecell); + } else { + treecell = treerow.childNodes[i]; + } if ( this.columns[i].editable == false ) { treecell.setAttribute('editable','false'); } if ( this.columns[i].type == 'checkbox') { treecell.setAttribute('value', labels[i]); } else { treecell.setAttribute('label',typeof labels[i] == 'string' || typeof labels[i] == 'number' ? labels[i] : ''); } - if (create_treecells) { treerow.appendChild( treecell ); } s += ('treecell = ' + treecell + ' with label = ' + labels[i] + '\n'); } @@ -1149,7 +1144,14 @@ util.list.prototype = { var treeitem = this.treechildren.childNodes[i]; var treerow = treeitem.firstChild; for (var j = 0; j < treerow.childNodes.length; j++) { - row[ obj.columns[j].id ] = treerow.childNodes[j].getAttribute('label'); + 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 { + row[ obj.columns[j].id ] = treerow.childNodes[j].getAttribute('label'); + } } dump.push( row ); } @@ -1358,8 +1360,15 @@ util.list.prototype = { for (var j = 0; j < treerow.childNodes.length; j++) { var value = treerow.childNodes[j].getAttribute('label'); if (params.skip_hidden_columns) if (obj.node.treeBoxObject.columns.getColumnAt(j).element.getAttribute('hidden') == 'true') continue; - var id = obj.columns[j].id; if (params.labels_instead_of_ids) id = obj.columns[j].label; - row[ id ] = value; + if (typeof obj.columns[j] == 'undefined') { + dump('=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n'); + dump('_dump_tree_selection_with_keys @ ' + location.href + '\n'); + dump('\ttreerow.childNodes.length='+treerow.childNodes.length+' j='+j+' obj.columns.length='+obj.columns.length+'\n'); + debugger; + } else { + var id = obj.columns[j].id; if (params.labels_instead_of_ids) id = obj.columns[j].label; + row[ id ] = value; + } } dump.push( row ); }