Complex Editor
来源:互联网 发布:淘宝小鸭软件 编辑:程序博客网 时间:2024/05/09 02:40
Complex Editor
Now suppose you want to do something a little more complex that doesn't have a ready-made Flex control available. Here is one which allows a credit card number to be entered using 4 separate 4-digit fields:
<mx:DataGrid x="46" y="463" editable="true" dataProvider="{accountDB}" width="302"><mx:columns><mx:DataGridColumn headerText="Account" dataField="account" width="100"/><mx:DataGridColumn headerText="Credit Card" dataField="ccard" editorDataField="value"><mx:itemEditor><mx:Component><mx:HBox><mx:Script><![CDATA[public function get value() : String{return part1.text+part2.text+part3.text+part4.text;}override public function set data(value:Object):void{super.data = value;part1.text = value.ccard.substr(0,4);part2.text = value.ccard.substr(4,4);part3.text = value.ccard.substr(8,4);part4.text = value.ccard.substr(12,4);}]]></mx:Script><mx:TextInput id="part1" maxChars="4" restrict="[0-9]" width="40" /><mx:TextInput id="part2" maxChars="4" restrict="[0-9]" width="40" /><mx:TextInput id="part3" maxChars="4" restrict="[0-9]" width="40" /><mx:TextInput id="part4" maxChars="4" restrict="[0-9]" width="40" /></mx:HBox></mx:Component></mx:itemEditor></mx:DataGridColumn></mx:columns></mx:DataGrid>
This inline itemEditor follows the same rules as other itemEditors and names the editorDataField as "value". The component chosen for the itemEditor is the HBox - which does not have a "value" property. To make this itemEditor work, a getter function named value is created to return the concatenation of the 4 input fields. Now when editing for the cell completes, the DataGrid can call upon the value property of the itemEditor and it will receive the combined fields.
You can also see that I have overridden the data setter function. In that function I split up the credit card number among the four TextInput fields. This is the technique you use to display the data to be edited. The editorDataField is the property used to retrieve the new value.
原文:http://weblogs.macromedia.com/pent/
- Complex Editor
- complex
- Complex
- Complex
- complex
- Complex
- Editor
- editor
- Editor
- Editor------------------Editor
- Class Complex
- Complex 赋值
- Complex类
- Complex类
- complex network1
- complex network2
- complex network3
- Complex Again
- datagrid如何传递多个值给另一个页面
- 用delphi开发Serv-U插件
- 做一个豁达的人
- VC中使用系统提供的线程池
- 服务数据库已锁定 两个可能
- Complex Editor
- C# Code Analyser 1.2.1 发布
- 杂七杂八——关于XAML与逻辑代码
- Flex and Hibernate
- 给C++增加“取引用”运算符
- 我不知道这是不是必然
- C# DDOS 攻击工 代码
- <<禮物 The Present >> 介绍
- Java编程那些事儿15——如何学好Java语