The properties of ClassFactory use [javascript] 1) UITextField and label. The label cannot be used to display [javascript] packagecom. citigroup. presentation. csa {importflash. events. MouseEvent; importmx. con
The usage of ClassFactory properties
[Javascript]
1) UITextField and label cannot be displayed using label
[Javascript]
Package com. citigroup. presentation. csa
{
Import flash. events. MouseEvent;
Import mx. controls. Label;
Import mx. controls. advancedDataGridClasses. AdvancedDataGridHeaderRenderer;
Import mx. core. UITextField;
Import mx. events. FlexEvent;
Public class GroupHeaderRenderer extends AdvancedDataGridHeaderRenderer
{
Public var children: Array = [];
Public var expand: Boolean = true;
Private var l: UITextField;
Public function GroupHeaderRenderer ()
{
Super ();
L = new UITextField ();
L. text = "[-]";
L. addEventListener (MouseEvent. CLICK, toggle );
AddChild (l );
This. addEventListener (FlexEvent. CREATION_COMPLETE, init );
}
Private function init (event: FlexEvent): void {
If (expand ){
L. text = "[-]";
} Else {
L. text = "[+]";
ToggleChildren (false );
}
This. removeEventListener (FlexEvent. CREATION_COMPLETE, init );
}
Override public function set data (value: Object): void {
Super. data = value;
This. setStyle ("color", "0xF9F088 ");
This. setStyle ("fontWeight", "bold ");
This. setStyle ("textAlign", "left ");
}
Override protected function updateDisplayList (unscaledWidth: Number, unscaledHeight: Number): void {
Super. updateDisplayList (unscaledWidth, unscaledHeight );
Label. x = 0;
L. x = label. x + label. width;
L. y = label. y;
}
Private function toggle (event: MouseEvent): void {
If (l. text = "[+]") {
L. text = "[-]";
ToggleChildren (true );
} Else {
L. text = "[+]";
ToggleChildren (false );
}
}
Private function toggleChildren (visible: Boolean): void {
If (children. length <= 1) return;
For (var I: int = 1; I Children [I]. visible = visible;
}
}
}
}
Public function genAdgColumn (headerText: String, dataField: String, width: Number = 100): AdvancedDataGridColumn {
Var col: AdvancedDataGridColumn = new AdvancedDataGridColumn ();
Col. headerText = headerText;
Col. dataField = dataField;
Col. width = width;
Return col;
}
Public function genAdgColumnGroup (headerText: String, dataField: String, children: Array, expand: Boolean = true): AdvancedDataGridColumnGroup {
Var group: AdvancedDataGridColumnGroup = new AdvancedDataGridColumnGroup ();
Group. headerText = headerText;
Group. dataField = dataField;
Var cf: ClassFactory = new ClassFactory (GroupHeaderRenderer );
Cf. properties = {'children ': children, 'expand': expand };
Group. headerRenderer = cf;
Group. children = children;
Return group;
}Author: rubyzhudragon