0
votes

I want to display some of the properties of an Object in the AdvancedDataGrid. How can I do that? I want to declare DataGridColumn and bind it to respective propery of an object.I have an ArrayCollection which contains many object of type resolutionVO.

If i don't declare columns and provide that arrayCollection to dataProvider of DataGrid then it displays all the columns but i don't want all.

When i declare columns and bind dataField to the respective properties of that object then DataGrid displays empty data. Please help how do i need to bind it?

Below is my 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>

And actionScript part is :

[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;
}

And Classes are :

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;
    }

}
2
Can you provide a sample code of your datagrid and data?zenbeni
My problem is how to bind each field?raju sharma
Does your data change in your application? You are trying to link a field which is inside an item of a collection of your class. You can make this work of course (if you are interested, I can show you how), but if the data contained in the collection changes, the databinding will break (you will have to do it manually). Datafield does not support "path" evaluation natively in DataGridColumn.zenbeni
No data does not change.raju sharma
i just want to know how to provide data to dataField . Thanks ..raju sharma

2 Answers

1
votes

Hiii, you can declare your arraycollection as the dataprovider and it will keep updating.

Annotate ArrayCollection as [Bindable] in the

[Bindable] ArrayCollection gridData;

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

Hoe its helpful

0
votes

You can define a 'virtual' field in your class ReportVO that does what your binding describes:

public function get virtualField():String {
     return ResolutionVO(this.resolutionReport.getItemAt(0)).SLMstatus;
}

And then you bind it in your DatagridColumn:

<mx:AdvancedDataGridColumn width="200" headerText="Incident ID" dataField="virtualField" editable="false"/>