如何在 AdvancedDataGrid 的列中绑定 flex ArrayCollection 的数据



我想在 AdvancedDataGrid 中显示对象的一些属性。我该怎么做?我想声明 DataGridColumn 并将其绑定到对象的相应属性。我有一个ArrayCollection,其中包含许多分辨率VO类型的对象。

如果我不声明列并将该 arrayCollection 提供给 DataGrid 的 dataProvider,那么它会显示所有列,但我不想要所有列。

当我声明列并将 dataField 绑定到该对象的相应属性时,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;
    }
}

Hiii,您可以将 arraycollection 声明为数据提供程序,它将不断更新。

[可绑定]阵列收集网格数据;

<mx:AdvancedDataGrid dataprovider={gridData}>
<mx:columns>
<mx:AdvancedDataGridColumn dataField="Album"/>
<mx:AdvancedDataGridColumn dataField="Price"/>
</mx:columns>
</mx:AdvancedDataGrid>

锄头很有帮助

您可以在类 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"/>

相关内容

  • 没有找到相关文章

最新更新