CellRenderer API: Need the interface?

Not sure if I’m doing this right, or if the interface is already in the framework, but here’s what I garnered from trying to make a cell renderer for the DataGrid:

<code>interface CellRenderer
{
// Returns the preferred height of a cell
function getPreferredHeight(Void):Number;

// Returns the preferred width of a cell
function getPreferredWidth(Void):Number;

// Sets the width and height of a cell
function setSize(width:Number, height:Number):Void;

// Sets the content to be displayed in the cell
function setValue(suggested, item, selected:Boolean):Void;
}</code>

I think if you throw that in an as file, and then #include it, you can then do:
<code>class YourClass implements CellRenderer{}</code>

At any rate, I’m using it that way, and if it breaks, or doesn’t compile, I’ll let you all know.

Comments

4 responses to “CellRenderer API: Need the interface?”

  1. Andrew Muller Avatar

    Jesse, you maniac, I keep meaning to play with the CellRenderer but there’s scant information out there – someone threatened to do a tutorial (Nig I think) but I’ve never seen one. It’s interesting that you can now use a CellRenderer for the V2 List component.

  2. jared chandler Avatar

    Would this be the easiest way to get alternating row colors in the datagrid?

  3. JesterXL Avatar

    Andrew, you rock!

    Bought to blog what I created… maybe it’ll be useful to you for seeing a Cell Renderer in action.

    Jared, not sure… I don’t see why not. The next post, I’ll post an idea.

  4. tiago Avatar

    to alternate colors in a list/grid
    array_of_two_colors = [0xFFFFFF, 0xEEEEEE];
    _global.style.setStyle(“alternateColor”, array_of_two_colors);

    dont remember exactly if is alternateColor or alternateRowColor, any way this is the simplest way to do it.