Skar,

the __labels hash should be keyed by the values, e.g. :
{
  "M":"Male",
  "F":"Female"
}

same for the __icons, e.g. :
{
  "M":"male.png",
  "F":"female.png"
}

Or you could even have a single structure, e.g. __labelsAndIcons:
{
  "M":["Male", "male.png"],
  "F":[
"Female", "female.png"]
}

Then the decision is made in the overriden _getContentHtml(cellInfo) method, inherited from the qx.ui.table.cellrenderer.Default renderer, based on the cellInfo.value that contains the actual cell value ("M" or "F"), performing the look up your renderer hashe(s), e.g. :

    _getContentHtml : function(cellInfo) {
      return this.__getImgHtml(cellInfo) + (this.__labels[cellInfo.value]||"");
    },
   
    __getImgHtml : function(cellInfo) {
      var rIcon = this.__icons[cellInfo.value];
      if(rIcon) {
        var w = 12;
        var h = 12;
        if(rIcon.getDimension()) {
          w = rIcon.getDimension().getWidth();
          h = rIcon.getDimension().getHeight();
        }
        var css = qx.bom.element.Style.compile({
          position : "relative",
          width : w + "px",
          height : h + "px",
          "margin-right" : "3px",
          "vertical-align" : "middle"
        });
        return '<img src="" style="' + css + '"/>';
      }
      return "";
    }

I hope I made it clearer ;-)

Best,
Vincent

skar a écrit :
Vincent Vandenschrick wrote:
  
Hi Skar,
Here is a renderer out of which you can get some inspiration. Basically, 
__labels is a hash of [value,translation] and __icons is a hash of 
[value,icons]. The cell model contains an enum value (e.g. "M" for 
"Male" and "F" for "Female").
  
    
Thanks for the code and the tips. Now, I've got the renderer created and
used like this:

  
var atomrenderer = new openprotect.AtomRenderer(
        [{"value":"Male"},{"value":"Female"}], //labels array of
value:translation of labels
        [{"value":"male.png"},{"value":"female.png"}]
      );
      tcm.setDataCellRenderer(5, atomrenderer);
    
Now, where's the logic which says use the Male label and icon if cell
value is "M" and the female one in case of "F"? Should it be in the
renderer or I set it as a conditional renderer?

cheers,
skar.

  


-- 
Vincent Vandenschrick
 Jspresso Framework
 http://www.jspresso.org
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to