我想在AdvancedDataGrid中显示Object的一些属性。我怎样才能做到这一点?我想声明DataGridColumn并将其绑定到对象的各个属性。我有一个ArrayCollection,其中包含许多类型为resolutionVO的对象。
如果我没有声明列并将该arrayCollection提供给DataGrid的dataProvider,那么它会显示所有列,但我不想要所有列。
当我声明列并将dataField绑定到该对象的相应属性时,DataGrid会显示空数据。请帮忙我如何绑定它?
以下是我的DataGrid:
<mx:AdvancedDataGrid id="resolutionDG" x="10" y="85" width="1153" height="300"
dataProvider="{filteredResolutionReport}" columnWidth="600" color="black">
<mx:columns >
<mx:AdvancedDataGridColumn width="200" headerText="Incident ID"
dataField="{((reportVO.resolutionReport as ArrayCollection).getItemAt(0) as ResolutionVO).incidentId}" editable="false" />
<mx:AdvancedDataGridColumn width="200" headerText="Priority"
dataField="{((reportVO.resolutionReport as ArrayCollection).getItemAt(0) as ResolutionVO).priority}" editable="true" />
<mx:AdvancedDataGridColumn width="200" headerText="SLM Status"
dataField="{((reportVO.resolutionReport as ArrayCollection).getItemAt(0) as ResolutionVO).SLMstatus}" />
<mx:AdvancedDataGridColumn width="200" headerText="Submit Date"
dataField="{((reportVO.resolutionReport as ArrayCollection).getItemAt(0) as ResolutionVO).submitDate}" />
<mx:AdvancedDataGridColumn width="200" headerText="Incident Resolved Date"
dataField="{((reportVO.resolutionReport as ArrayCollection).getItemAt(0) as ResolutionVO).incidentResolvedDate}" />
</mx:columns>
</mx:AdvancedDataGrid>
动作脚本部分是:
[Bindable]
public var reportVO:ReportVO;
[Bindable]
public var resolutionReport:ArrayCollection;
[Bindable]
public var resolutionVO:ResolutionVO;
[Bindable]
public var filteredResolutionReport:ArrayCollection;
public function resultHandler(event:ResultEvent):void
{
resolutionReport=reportVO.resolutionReport;//
filteredResolutionReport=reportVO.resolutionReport;
}
而且课程是:
1)ReportVO.as
[Bindable]
[RemoteClass(alias="com.adobe.sla.valueObject.ReportVO")]
public class ReportVO
{
private var _resolutionReport:ArrayCollection;
private var _responseReport:ArrayCollection;
public function ReportVO()
{
}
public function get responseReport():ArrayCollection
{
return _responseReport;
}
public function set responseReport(value:ArrayCollection):void
{
_responseReport = value;
}
public function get resolutionReport():ArrayCollection
{
return _resolutionReport;
}
public function set resolutionReport(value:ArrayCollection):void
{
_resolutionReport = value;
}
}
2)ResolutionVO.as
[Bindable]
[RemoteClass(alias="com.adobe.sla.valueObject.ResolutionVO")]
public class ResolutionVO
{
private var _assignedGroup:String;
private var _incidentId:String;
private var _priority:String;
private var _SLMstatus:String;
public function ResolutionVO()
{
}public function get SLMstatus():String
{
return _SLMstatus;
}
public function set SLMstatus(value:String):void
{
_SLMstatus = value;
}
public function get priority():String
{
return _priority;
}
public function set priority(value:String):void
{
_priority = value;
}
public function get incidentId():String
{
return _incidentId;
}
public function set incidentId(value:String):void
{
_incidentId = value;
}
public function get assignedGroup():String
{
return _assignedGroup;
}
public function set assignedGroup(value:String):void
{
_assignedGroup = value;
}
}
答案 0 :(得分:1)
Hiii,你可以将你的arraycollection声明为dataprovider,它会不断更新。
在
中将ArrayCollection注释为[Bindable][绑定] ArrayCollection gridData;
<mx:AdvancedDataGrid dataprovider={gridData}>
<mx:columns>
<mx:AdvancedDataGridColumn dataField="Album"/>
<mx:AdvancedDataGridColumn dataField="Price"/>
</mx:columns>
</mx:AdvancedDataGrid>
锄头有用
答案 1 :(得分:0)
您可以在类ReportVO中定义一个“虚拟”字段,该字段执行绑定所描述的内容:
public function get virtualField():String {
return ResolutionVO(this.resolutionReport.getItemAt(0)).SLMstatus;
}
然后在DatagridColumn中绑定它:
<mx:AdvancedDataGridColumn width="200" headerText="Incident ID" dataField="virtualField" editable="false"/>