Hi, I have a question about customizations of TreeTable class. I'm working in
a project that needs a highly customized version of TreeTable. It implies
the overriding of methods that are actually private or final methods and a
customized version of TreeTable.html too. Our version of TreeTable.html
includes the addition of new elements at the same level as
"wicket-tree-table" and "wicket-tree-table-body" divs. That broken the
algorithm of Wicket.TreeTable.update function in tree.js, because it assumes
a fixed structure for TreeTable.html. So I have to copy several wicket tree
and table packages into my project to get acces to the source of tree.js and
modify it. here is my implementation of it:

Wicket.TreeTable.update = function(elementId) {
   var header;
   var headerInnerDiv; // div inside header div. It is set with the updated
size.
   var body;
   var wicketTreeTable;
   var headerFound = false;
   var bodyFound = false;
   var wicketTreeTableFound = false;
  
   var element = document.getElementById(elementId);
  
   if (element != null && typeof(element) != "undefined") {
     
      try {
         var tableDivs = element.getElementsByTagName("div");
         for (i=0; i < tableDivs.length && (!headerFound || !bodyFound ||
!wicketTreeTableFound); i++) { 
            //Pick out the tags with our class name 
            if (tableDivs[i].className.search("header ") != -1) {
               header = tableDivs[i];
               headerInnerDiv = header.getElementsByTagName("div")[0];
               headerFound = true;
            }
            if (tableDivs[i].className.search("wicket-tree-table-body") !=
-1) { 
               body = tableDivs[i];
               bodyFound = true;
            }
            if (tableDivs[i].className.search("wicket-tree-table") != -1) { 
               wicketTreeTable = tableDivs[i];
               wicketTreeTableFound = true;
            }
         }

         // last check to find out if we are updating the right component
         if (body.className.search("wicket-tree-table-body") != -1) {
            // get the right padding from header - we need to substract it
from new width
            var padding;
            if (document.defaultView &&
document.defaultView.getComputedStyle) {
               padding =
document.defaultView.getComputedStyle(wicketTreeTable,
'').getPropertyValue("padding-right");
            } else if (wicketTreeTable.currentStyle) {
               padding = wicketTreeTable.currentStyle.paddingRight;
            } else {
               padding = 6;
            }
           
            padding = parseInt(padding, 10);
                             
            // set the new width      
            var w = (body.getElementsByTagName("div")[0].clientWidth -
padding) + "px";
           
            if (w == (-padding)+"px") { // this can happen if the first row
is hidden (e.g. rootless mode)
               // try to get the width from second row   
               w = (body.getElementsByTagName("div")[1].clientWidth -
padding) + "px";
              
            }
              
            if (w != "0px") {
               headerInnerDiv.style.width = w;
            }
           
         }
      } catch (ignore) {        
      }
   }
}


What I changed is the look up for the relevant elements, I do the search by
class name, so it doesn't depend on the structure of the html.


Another issue is the class test of the form: body.className ==
"wicket-tree-table-body", say the check for the exact class name. We have
this divs with several classes (for example class="wicket-tree-table-body
class1 classN"), We have changed that test to the form:
body.className.search("wicket-tree-table-body") != -1 to allow the addition
of more classes to those elements.

I'd like you to tell me if this kind of changes is nor recommended and for
what reasons (performance maybe?) and if on the contrary they could be
incorporated in future releases of wicket and the
TreeTable.

 
Thanks a lot.
-- 
View this message in context: 
http://www.nabble.com/TreeTable-customization-tp19089113p19089113.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to