User Guide

CellRenderer.setValue() 125
Parameters
suggested A value to be used for the cell renderers text, if any is needed.
item An object that is the entire item to be rendered. The cell renderer can use properties of
this object for rendering.
selected A string with the following possible values: "normal", "highlighted", and
"selected".
Returns
Nothing.
Description
Method; takes the values given and creates a representation of them in the cell. This resolves
any difference between what was displayed in the cell and what needs to be displayed in the
cell for the new item. (Remember that any cell could display many values during its time in
the list.) This is the most important CellRenderer method, and you must implement it in
every cell renderer.
The
setValue() method is called frequently (for example, when a rollover, a selection,
column resizing, or scrolling occurs). It is important to remember that a cell might not exist
on the Stage and should not always be updated with data when
setValue() is called. For
example, at any moment, a particular cell may be scrolled out of the display area or it might
be reused to render another value. For this reason, you cannot directly reference a specific cell
renderer instance in the grid, and you should write
if statements in the body of setValue()
that allow code to run only if the
item parameter is defined and a change has occurred. An
undefined item parameter indicates that the cell should be visibly empty and any items in the
cell should be assigned a
_visible property of false. Cells can be required to be visibly
empty temporarily, such as when scrolling occurs in a DataGrid.
If a row is selected and the pointer is over it, the value of the selected parameter is
"highlighted", not "selected". This can cause problems if youre trying to make the cell
renderer behave differently according to whether the row is in a selected state. To test whether
the current row is in a selected state, use the following code:
var reallySelected:Boolean = selected != "normal" && listOwner.selectedNode
== item;
Example
The following example shows how to use setValue() and editField() to reference a cell
renderer instance in a grid.