Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Cannot read an ArrayCollection variable assigned by LCDS


Former Community Member
Hi,<br /><br /> I am new to flex and lcds. pls. help me to understand. All I am trying to do here is take the hibernate sample from lcds sample application and replace the grid control with a tree control. In order achieve this, I was trying to convert the ArrayCollection into an XMLListCollection object through an actionscript in a function called convertToXML. How ever, I'm having the difficulty in this conversion. When i tried to debug the action script, the arraycollection, which is suppose to be with full values, seems to empty. But, still it shows up the records in the grid. pls. help to understand, why, I can't manipulate the ArrayCollection?<br /><br /> For your reference, Following is the modifed modified lines of the original lcds sample code.<br /><br /><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:local="*" layout="absolute" <br /> width="100%" height="100%"<br /> pageTitle="Hibernate"<br /> creationComplete="convertToXML()"><br /><br /> <!--<br /> <mx:Tree id="list" width="100%" height="100%" dataProvider="{projectData}" labelField="@name"/><br /> --><br /> <mx:DataGrid id="list" width="100%" height="100%" dataProvider="{contacts}"<br /> doubleClick="openTab(list.selectedItem as Contact)" doubleClickEnabled="true"><br /> <mx:columns><br /> <mx:DataGridColumn dataField="firstName" headerText="First Name"/><br /> </mx:columns><br /> </mx:DataGrid><br /><br /> [Bindable]<br /> private var projects:XML =<br /> <list><br /> <projects name="Projects" code="0"><br /> </projects><br /> </list>;<br /><br /> [Bindable]<br /> private var projectData:XMLListCollection = <br /> new XMLListCollection(projects.projects);<br /> <br /> private function convertToXML():void {<br /> ds.fill(contacts, 'all', []);<br /> for each (var proj:Contact in contacts) {<br /> addProject(proj.lastName + ", " + proj.firstName); <br /> } <br /> }<br /> <br /> private function addProject(projName:String):void {<br /> var newNode:XML = <project/>;<br /> newNode.@name = projName;<br /> var proj:XMLList = projects.projects.(@name == "Projects");<br /> if( proj.length() > 0 ) {<br /> proj[0].appendChild(newNode);<br /> }<br /> }<br /><br /> private function treeLabel(item:Object):String {<br /> var node:XML = XML(item);<br /> if( node.localName() == "department" )<br /> return node.@title;<br /> else<br /> return node.@name;<br /> }
0 Replies