flex4学习开篇 如何在datagrid中插入DropDownList,并且获取selectedItem
来源:互联网 发布:js遍历dom树 编辑:程序博客网 时间:2024/04/26 05:49
刚开始学习flex,一切都是还在摸索阶段,目前做的项目遇到了一个问题,datagrid里itemRenderer的值无法获取。
1、从itemRenderer获取外面的值可以用outerDocument方式;
2、但是外层如何获取itemRenderer里的呢?比如说DropDownList的selectedItem
我把握的代码贴上来,并且解释下思路。各位大侠当然有更好的办法,勿喷我,我只是个菜鸟
editable="true"
headerText="类型"
labelFunction="lbAPPLICATIONTYPEFun">
<s:itemRenderer>
<fx:Component>
<s:GridItemRenderer>
<s:TextInput id="tiItemDrop"
text="{data.TYPE=="1"?"工业A":"工业B"}"
width="100%" height="100%"
borderVisible="false"
editable="false">
</s:TextInput>
<s:TextInput id="tiItemDropFalse"
text="@{data.TYPE}"
width="100%" height="100%"
borderVisible="false"
visible="false"
editable="false">
</s:TextInput>
<s:DropDownList id="dpDataList"
enabled="{data.opera}"
visible="{data.opera}"
width="100%" height="100%"
selectedIndex="{Number(data.TYPE)-1}"
close="on_dbChooseClose_Handler(event)">
<s:ArrayList>
<fx:Object data="1" label="工业A"/>
<fx:Object data="2" label="工业B"/>
</s:ArrayList>
</s:DropDownList>
<fx:Script>
<![CDATA[
import spark.events.DropDownEvent;
protected function on_dbChooseClose_Handler(event:DropDownEvent):void
{
ClosedpDataList()
}
public function ClosedpDataList():void
{
tiItemDropFalse.text=dpDataList.selectedItem.data;
tiItemDrop.text=dpDataList.selectedItem.label;
//dpDataList.visible=false;
}
]]>
</fx:Script>
</s:GridItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:GridColumn>
上面代码中标红的地方是重要的思路,我做了一个隐藏域,把DropDownList选择出来的值赋给这个隐藏域,然后通过隐藏域与外面的
text="@{data.TYPE}" 进行双向绑定,这样我就同时修改了这个值,这个只是我的思路,通过这个思路同时解决了我在datagrid里插入
dataField的问题,也附上我的代码,思路一样,不做解释:
<s:GridColumn dataField="SIGNDATE"editable="true"
headerText="签约时间"
labelFunction="lbAPPLICATIONDATEFun">
<s:itemRenderer>
<fx:Component>
<s:GridItemRenderer>
<s:TextInput id="tiItemDateField"
text="{DateUtils.format(data.SIGNDATE,DateUtils.FMT_ISO_DATE)}"
width="100%" height="100%"
borderVisible="false"
editable="{data.opera}">
</s:TextInput>
<s:TextInput id="tiItemDateFieldFalse"
text="@{data.SIGNDATE}"
width="100%" height="100%"
borderVisible="false"
visible="false"
editable="{data.opera}">
</s:TextInput>
<mx:DateField id="dfDataList"
width="100%" height="100%"
editable="false"
visible="{data.opera}"
dayNames="{DateUtils.DAYS}"
formatString="{DateUtils.FMT_ISO_DATE}"
monthNames="{DateUtils.MONTHS}"
selectedDate="{ new Date(data.SIGNDATE.split("-")[0],
data.SIGNDATE.split("-")[1]-1,
data.SIGNDATE.split("-")[2].split("T")[0])} "
change="on_dbChooseClose_Handler()"/>
<fx:Script>
<![CDATA[
import Utility.Time.DateTime;
import Utility.Time.DateUtils;
protected function on_dbChooseClose_Handler():void
{
ClosedfDataList()
}
public function ClosedfDataList():void
{
tiItemDateField.text=DateUtils.format(dfDataList.selectedDate,DateUtils.FMT_ISO_DATE);
tiItemDateFieldFalse.text=DateUtils.format(dfDataList.selectedDate,DateUtils.FMT_ISO_DATE)+"T";
}
]]>
</fx:Script>
</s:GridItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:GridColumn>
- flex4学习开篇 如何在datagrid中插入DropDownList,并且获取selectedItem
- 如何实现在DataGrid中实现DropDownList控件的联动
- 在一个DataGrid中加入一个DropDownList后如何给DropDownList赋值
- 在PHP中获取IP来源地址并且插入数据库
- 在datagrid中添加dropdownlist控件
- 如何在datagrid中用dropdownlist显示当前行的记录
- DropDownList中在数据绑定后如何插入第一项提示
- 【flex4】datagrid中使用combox
- 在DataGrid中使用DropDownList控件 (转 土人制造)
- ASP.NET DEMO 14: 如何在 GridView/DataGrid 模板列中使用自动回发的 CheckBox/DropDownList
- ASP.NET DEMO 14: 如何在 GridView/DataGrid 模板列中使用自动回发的 CheckBox/DropDownList
- 在GridView的中有一个DropDownList,并且DropDownList有回传事件
- 如何初始化DataGrid中的DropDownList
- DataGrid模版中嵌入了dropdownlist,如何触发这个dropdownlist的事件
- 自己解决如何获取在DropDownList中添加的自定义属性的值
- DropDownList.SelectedItem与DropDownList.SelectedValue的区别
- DropDownList.SelectedItem与DropDownList.SelectedValue的区别
- Flex4 中将网页的参数传递给Flash,并且在Flash中读取这些参数
- Follow your heart, always remember who you are, what you want to be.
- Andriod应用开发之你必须知道 Service 用法
- Smartform 和 drive program的开发流程
- 下沙小面的(2)
- linux下何谓.so文件
- flex4学习开篇 如何在datagrid中插入DropDownList,并且获取selectedItem
- 通讯串口
- FORM 开发相关技巧1
- hiveQL分区表
- win7 和 ubuntu 双系统, 重装win7 后恢复ubuntu引导
- 关于Ubuntu系统笔记本在电池模式下鼠标等外设失去响应的解决办法
- Android应用开发之你必须知道如何在Android4.0上开发多屏幕适配的应用
- 值传递还是址传递,走出误区
- FORM 开发相关技巧2