I've been having trouble setting the item renderer of a Spark DataGrid in CSS and then I remembered the compiler creates a class factory for it.
This CSS does not work:
.myGrid {
itemRenderer: ClassReference("myItemRenderer");
}
but declaring it inline it does:
<s:DataGrid itemRenderer="myItemRenderer" />
I found this setStyle
code and put it in the constructor but it doesn't work:
public function DataGrid() {
super();
setStyle("itemRenderer", new ClassFactory(myItemRenderer));
}
I've created a new control and I want to use my custom renderer as default. So all the styles are set in the defaults.css.
I can't set a class factory in CSS for this property. I think the property needs to be a IFactory and defined as a style.
I can set an item renderer with the DataGrid. I can set it in the constructor using:
public function DataGrid() {
super();
itemRenderer = new ClassFactory(myItemRenderer);
}
or in the DataGrid skin:
<s:Scroller id="scroller" minViewportInset="1" hasFocusableChildren="false" height="100%">
<!--- @private -->
<s:Grid id="grid" itemRenderer="MyGridItemRenderer">
</s:Grid>
</s:Scroller>