I am trying display values in a datagrid in my application. I have all the values as an xml file. I had only one set of record n the XML file, to fill only one row of the data grid. While trying to store the values from the XML file to an Array Collection in the application File using the code, i.e.,
<mx:Model id="reviewList" source="assets/reviewList.xml"/>
<mx:ArrayCollection id="reviewlist" source="{reviewList.Item}"/>
I get an error, saying
Error No# 1034: Type coercion failed cannot convert mx.utils::ObjectProxy to Array.
But If I have two record sets in the XML file, it works fine. If there is only one set, I get the above said error? What is the problem in this case?
Here is my xml file:
<ReviewList>
<Item>
<ReviewId>1123</ReviewId>
<TaskType>User Requirement Specification</TaskType>
<RequestId>1223</RequestId>
<ItemCodeVersion>URS - 1</ItemCodeVersion>
<ReviewStartDate>29-Sep-2009</ReviewStartDate>
<Status>Review In Progress</Status>
<Reviewer>MR.RISHU GHOSE</Reviewer>
<OpenDefect>0</OpenDefect>
<CasualAnalysisPending>0</CasualAnalysisPending>
<CloseDefects>0</CloseDefects>
<VerifiedDefects>0</VerifiedDefects>
</Item>
</ReviewList>
And this is the datagrid where I want the details to be displayed.
<mx:DataGrid id="reviewDG" dataProvider="{reviewlist}" variableRowHeight="true" width="100%" height="200"
horizontalScrollPolicy="off">
<mx:columns>
<mx:DataGridColumn headerText="Review Id" dataField="ReviewId" textAlign="center" />
<mx:DataGridColumn headerText="Task Type" dataField="TaskType" textAlign="center"/>
<mx:DataGridColumn headerText="Request Id" dataField="RequestId" textAlign="center"/>
<mx:DataGridColumn headerText="Item Code-Ver" dataField="ItemCodeVersion" textAlign="center" headerWordWrap="true"/>
<mx:DataGridColumn headerText="Review Start Date" dataField="ReviewStartDate" textAlign="center" headerWordWrap="true"/>
<mx:DataGridColumn headerText="Status" dataField="Status" textAlign="center"/>
<mx:DataGridColumn headerText="Reviewer" dataField="Reviewer" textAlign="center"/>
<mx:DataGridColumn headerText="Open Defect" dataField="OpenDefect" textAlign="center" headerWordWrap="true"/>
<mx:DataGridColumn headerText="Casual Analysis Pending" dataField="CasualAnalysisPending" textAlign="center" headerWordWrap="true"/>
<mx:DataGridColumn headerText="Close Defects" dataField="CloseDefects" textAlign="center" headerWordWrap="true"/>
<mx:DataGridColumn headerText="Verified Defects" dataField="VerifiedDefects" textAlign="center" headerWordWrap="true"/>
<mx:DataGridColumn headerText="Review Details" dataField="ReviewDetails" width="65" headerWordWrap="true">
<mx:itemRenderer>
<mx:Component>
<mx:Label text="View" click="outerDocument.onViewClick()"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
There may be cases in my application where i need only one record to be displayed in the datagrid. In such cases how do I resolve this error?