I'm trying to create item renderers for DataGrid columns dynamically
at runtime and am having a hard time sorting out how to define and
attach item renderers. To make sure I've got the mecahnics right
first, all I'm trying for now is to make a non-editable column display
as a checkbox. My column definitions are stored in an XML file - the
snipped below shows how I'm reading the definitions and creating the
DataGrid's columns:

for each (var columnDefinition:XML in columnDefinitionsXmlList) {               
                
        var newColumn:DataGridColumn = new DataGridColumn;
        newColumn.headerText = columnDefinition.col_title;
        newColumn.dataField = columnDefinition.col_data;
        newColumn.width = Number(columnDefinition.col_width);
        if (columnDefinition.col_type == "boolean") {
                // newColumn.itemRenderer =  new 
ClassFactory(mx.controls.CheckBox);
                var cb:ClassFactory = new ClassFactory(mx.controls.CheckBox);
                        newColumn.itemRenderer = cb;
                }
        
        columnDefinitions.push(newColumn);
        }

The code shown above does make the column display as a checkbox - but
there's no code to turn the checkbox on/off depending on the current
cell's value. In the example above, the variable cb is the checkbox
that is then associated with the column. What I don't see in
FlexBuilder's hinting system is any property of cb that lets me set
the condition that controls if the checkbox is on or off - or any of
the other properties normally used for an item renderer defined
through MXML.

Am I missing something obvious or am I going about this in the wrong way?

Links to any relevant examples appreciated - I've looked at a lot of
examples, but have yet to find one that shows defining an item
renderer in quite this way. I'm happy to create a class or component
for CheckBox (or whatever else) so long as I'll then be able to set
the condition which controls on/off.

Thanks for any help.

Reply via email to