0

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

}
5
  • Can you provide a sample code of your datagrid and data? Commented Feb 19, 2014 at 15:28
  • My problem is how to bind each field? Commented Feb 19, 2014 at 15:53
  • 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. Commented Feb 19, 2014 at 16:01
  • No data does not change. Commented Feb 19, 2014 at 16:03
  • i just want to know how to provide data to dataField . Thanks .. Commented Feb 19, 2014 at 16:06

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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"/>

4 Comments

Thanks zenbeni. I will implement it and let you know.
@rajusharma Is your collection empty before your DataGrid is instanciated?
yes. But what i think is when data comes from remote object's method call then it should be displayed which happens when i don't declare any column. My assumption might be wrong . Plz suggest.
@rajusharma you should add items to the dataprovider only if their resolutionReport collection has items, if not, as the databinding is not routed, the first evaluation is shown (no value).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.