Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 如何在datagrid中添加datefield_Actionscript 3_Apache Flex_Flex3_Flash Builder - Fatal编程技术网

Actionscript 3 如何在datagrid中添加datefield

Actionscript 3 如何在datagrid中添加datefield,actionscript-3,apache-flex,flex3,flash-builder,Actionscript 3,Apache Flex,Flex3,Flash Builder,我有一个带有可编辑属性的datagrid,在一列中显示日期信息。 日期以字符串格式存储在数据提供程序中。(这些日期来自httpservice的数据库)。 但是我想在我的datagrid列中添加一个itemEditor。 为了做到这一点,我尝试了 <mx:DataGridColumn dataField="echElemDate" headerText="MyHeaderDate" headerStyleName="dgHeader" fontWeight="normal"

我有一个带有可编辑属性的datagrid,在一列中显示日期信息。 日期以字符串格式存储在数据提供程序中。(这些日期来自httpservice的数据库)。 但是我想在我的datagrid列中添加一个itemEditor。 为了做到这一点,我尝试了

 <mx:DataGridColumn dataField="echElemDate"  headerText="MyHeaderDate" 
     headerStyleName="dgHeader" fontWeight="normal" 
      itemEditor="mx.controls.DateField" editorDataField="text"/>
你能帮我解决这个错误吗


感谢您尝试更改headerText=DateString,并确保插入mx:datagrid editable=“true”

如果在数据提供程序中有可控制AS类的AS对象,最简单的方法是在类中添加一个getter和setter,并使用转换StringDate,如下所示:

public function get echElemDateAsDate():Date {
    return DateField.stringToDate(this.echElemDate, "DD/MM/YYYY");
}

public function set echElemDateAsDate(value:Date) {
     this.echElemDate = DateField.dateToString(value, "DD/MM/YYYY");
}

如果您不能控制该类,那么我认为您必须使用editorDataField=“selectedDate”进行自定义项编辑器。因为编辑结束时,它会将DateField[editorDataField]转换为data[dataField]

@huang.xinghui给了你有用的建议,你试过这段代码吗?我再现了你的情况,这很有帮助

<mx:DataGridColumn dataField="echElemDate"  headerText="MyHeaderDate" 
                               headerStyleName="dgHeader" fontWeight="normal" 
                               itemEditor="mx.controls.DateField" editorDataField="selectedDate"/>


谢谢你的回答,但这并没有解决我的问题。事实上,我的datagrid是可编辑的,headerText不是我的dataprovider中的问题,我没有AS对象。那么,我可以在itemrenderer中使用您的答案以及override set and get data方法吗?对于set data,可以。对于get不确定,我不记得如何将来自项编辑器的数据放回数据提供程序中。
<mx:DataGridColumn dataField="echElemDate"  headerText="MyHeaderDate" 
                               headerStyleName="dgHeader" fontWeight="normal" 
                               itemEditor="mx.controls.DateField" editorDataField="selectedDate"/>