How to Set attributes in Renderer

Source: Internet
Author: User
Tags csa
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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.