FLEX string类型的数据如何显示在datefield中?
谁能让这个按下去不出错啊<?xmlversion="1.0"encoding="utf-8"?><mx:Applicationxmlns:mx="http://www.a...
谁能让这个按下去不出错啊
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init()" width="100%" height="100%" fontSize="12" dataChange="init()">
<mx:Style>
.errorTip {fontSize:"12"}
DataGrid{
headerStyleName: "mydataGridHeaderStyle";}
.mydataGridHeaderStyle {
color: #ff0000;
fontWeight: bold;}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
[Bindable]
private var today:Date = new Date(new Date().setHours(0,0,0,0));
[Bindable]
private var start:Date = today;
import mx.collections.XMLListCollection;
//import common.XmlTool;
//import common.PubPar;
import mx.controls.Alert;
import mx.events.ValidationResultEvent;
private var TOTLE_MONEY:Number;
private var EXE_OK:Number;
public var mininum:Number=1;
public var maximum:Number=100;
public var num:int=0;//请保持这里的数字等于默认添加条-1//不然添加会出现不能添加
public var numd:int=0;
public var addEXE_MONEY:int=0;
public var addEXE_RATIO:int=0;
public var oldEXE_RATIO:int=0;
[Bindable]
public var testXML:XML=<root>
<SETTLEMENT TOTLE_MONEY="" EXE_OK="1">
<r EXE_MONEY="0" EXE_RATIO="0" EXE_DATE="0-0-0" EXE_OK="2" />
</SETTLEMENT>
</root>;
private function init():void{
var monthb:String=today.month+1+"";
var dateb:String=today.date+"";
if(today.month.toString().length==1){
monthb="0"+monthb
}
if(today.date.toString().length==1){
dateb="0"+dateb
}
testXML.SETTLEMENT[0].r[XMLList(testXML.SETTLEMENT[0].r).length()-1].@EXE_DATE=today.fullYear+"."+monthb+"."+dateb
var rList:XMLList=testXML.SETTLEMENT[0].r;
myGrid.dataProvider=rList;
}
]]>
</mx:Script>
<mx:DataGrid styleName="DataGrid" editable="true" id="myGrid" width="314" height="286" >
<mx:columns>
<mx:DataGridColumn headerText="执行日期" width="100" dataField="@EXE_DATE">
<mx:itemEditor>
<mx:Component>
<mx:DateField creationComplete="initDate()" formatString="YYYY.MM.DD">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function initDate():void{
//Alert.show(data.@EXE_DATE+"PP");
text=data.@EXE_DATE;
//text=data.today.fullYear+"."+data.monthb+"."+data.dateb
}
]]>
</mx:Script>
</mx:DateField>
</mx:Component>
</mx:itemEditor>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Application>
没人会,哈哈,尽然没人会哦,唉,人在多也没用,欺啊 展开
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init()" width="100%" height="100%" fontSize="12" dataChange="init()">
<mx:Style>
.errorTip {fontSize:"12"}
DataGrid{
headerStyleName: "mydataGridHeaderStyle";}
.mydataGridHeaderStyle {
color: #ff0000;
fontWeight: bold;}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
[Bindable]
private var today:Date = new Date(new Date().setHours(0,0,0,0));
[Bindable]
private var start:Date = today;
import mx.collections.XMLListCollection;
//import common.XmlTool;
//import common.PubPar;
import mx.controls.Alert;
import mx.events.ValidationResultEvent;
private var TOTLE_MONEY:Number;
private var EXE_OK:Number;
public var mininum:Number=1;
public var maximum:Number=100;
public var num:int=0;//请保持这里的数字等于默认添加条-1//不然添加会出现不能添加
public var numd:int=0;
public var addEXE_MONEY:int=0;
public var addEXE_RATIO:int=0;
public var oldEXE_RATIO:int=0;
[Bindable]
public var testXML:XML=<root>
<SETTLEMENT TOTLE_MONEY="" EXE_OK="1">
<r EXE_MONEY="0" EXE_RATIO="0" EXE_DATE="0-0-0" EXE_OK="2" />
</SETTLEMENT>
</root>;
private function init():void{
var monthb:String=today.month+1+"";
var dateb:String=today.date+"";
if(today.month.toString().length==1){
monthb="0"+monthb
}
if(today.date.toString().length==1){
dateb="0"+dateb
}
testXML.SETTLEMENT[0].r[XMLList(testXML.SETTLEMENT[0].r).length()-1].@EXE_DATE=today.fullYear+"."+monthb+"."+dateb
var rList:XMLList=testXML.SETTLEMENT[0].r;
myGrid.dataProvider=rList;
}
]]>
</mx:Script>
<mx:DataGrid styleName="DataGrid" editable="true" id="myGrid" width="314" height="286" >
<mx:columns>
<mx:DataGridColumn headerText="执行日期" width="100" dataField="@EXE_DATE">
<mx:itemEditor>
<mx:Component>
<mx:DateField creationComplete="initDate()" formatString="YYYY.MM.DD">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function initDate():void{
//Alert.show(data.@EXE_DATE+"PP");
text=data.@EXE_DATE;
//text=data.today.fullYear+"."+data.monthb+"."+data.dateb
}
]]>
</mx:Script>
</mx:DateField>
</mx:Component>
</mx:itemEditor>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Application>
没人会,哈哈,尽然没人会哦,唉,人在多也没用,欺啊 展开
3个回答
展开全部
你得重写 set data方法 你新建下面这个mxml文件,用另一种格式
然后<mx:DataGridColumn headerText="执行日期" width="100" itemEditor="文件名"/>
<?xml version="1.0" encoding="utf-8"?>
<mx:DateField xmlns:mx="http://www.adobe.com/2006/mxml" formatString="YYYY.MM.DD">
<mx:Script>
<![CDATA[
import mx.controls.listClasses.BaseListData;
import mx.controls.listClasses.ListData;
import mx.events.FlexEvent;
import mx.controls.dataGridClasses.DataGridListData;
private var _data:Object;
private var _listData:BaseListData;
private var selectedDateSet:Boolean;
override public function get listData():BaseListData
{
return _listData;
}
/**
* @private
*/
override public function set listData(value:BaseListData):void
{
_listData = value;
}
override public function set data(value:Object):void
{
var newDate:Date;
_data = value;
var str:String=_data[DataGridListData(_listData).dataField];
if(str==null)
str="";
newDate = DateField.stringToDate(str,"YYYY.MM.DD");
if (!selectedDateSet)
{
selectedDate = newDate;
selectedDateSet = false;
}
dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
}
override public function get data():Object
{
return _data;
}
]]>
</mx:Script>
</mx:DateField>
然后<mx:DataGridColumn headerText="执行日期" width="100" itemEditor="文件名"/>
<?xml version="1.0" encoding="utf-8"?>
<mx:DateField xmlns:mx="http://www.adobe.com/2006/mxml" formatString="YYYY.MM.DD">
<mx:Script>
<![CDATA[
import mx.controls.listClasses.BaseListData;
import mx.controls.listClasses.ListData;
import mx.events.FlexEvent;
import mx.controls.dataGridClasses.DataGridListData;
private var _data:Object;
private var _listData:BaseListData;
private var selectedDateSet:Boolean;
override public function get listData():BaseListData
{
return _listData;
}
/**
* @private
*/
override public function set listData(value:BaseListData):void
{
_listData = value;
}
override public function set data(value:Object):void
{
var newDate:Date;
_data = value;
var str:String=_data[DataGridListData(_listData).dataField];
if(str==null)
str="";
newDate = DateField.stringToDate(str,"YYYY.MM.DD");
if (!selectedDateSet)
{
selectedDate = newDate;
selectedDateSet = false;
}
dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
}
override public function get data():Object
{
return _data;
}
]]>
</mx:Script>
</mx:DateField>
展开全部
方法有很多,提供一种我所使用的方法
将一行的所有元素作为一个类的属性
实例化类后,加入集合或数组将数组赋给table的dataprovide属性
然后再每一列赋予元素属性即可,flex会自动进行递归数据绑定的
将一行的所有元素作为一个类的属性
实例化类后,加入集合或数组将数组赋给table的dataprovide属性
然后再每一列赋予元素属性即可,flex会自动进行递归数据绑定的
追问
已经试过好多方法了,都已经贴出全部代码了,能改好通过发出来吗,谢谢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
flex中,在DateField上只能显示年月日,我现在想添加一个控件,使其能够显示formatString=
追问
会的话改好发出来,通过就给分,帮帮忙,其他方法就说明详细操作,编程刚接触不太懂
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询