I have looked over the CMORGCHART, CGLOGIN, and CGSTORE examples, and I guess I am stupid cause I still cannot get model variables to update.
What I am trying to do is simple. I have a grid, that contains an array collection of ship objects. I have a shipdetails screen. What I want to do is display the details of the ship object selected in the ship grid, on the ship details pane. The view layout is simple, I have a Vbox, called ShipBody, it contains, both the ShipGrid, and ShipDetails components. On my model, I have an arrayCollection called ships. It is my returned value from the service I call. The Ship Grid object uses that variable on model, for its dataprovider. On my ShipDetails component I have a variable called shipSelected which is of type ShipVO, the same type of variable is set on the grid component of the same object type. Then from the details component each of the text fields are set to shipSelected.attrbuteName. When I call the ShipDetails component from the ShipBody component, I tell it to set the shipSelected variable to the model.selectedShip. However the problem comes in from the grids perspective. I cannot seem to get the grid to actually change the model.selectedShip attribute. So if ship number one is intially set on the result handler from the service, no matter that the change event seems to fire from the ShipGrid component, it never updates the model. Here is the code: First the body section which houses both components: <mx:Canvas label="Ships" xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:ships="com.cardinal.flex.cruise.view.cruise.ships.*" width="100%" height="100%" > <mx:Script> <![CDATA[ import com.cardinal.flex.cruise.model.CruiseModelLocator; [Bindable] public var model : CruiseModelLocator = CruiseModelLocator.getInstance(); ]]> </mx:Script> <mx:VDividedBox x="0" y="0" height="415" width="978"> <ships:shipGrid id="ShipListDataGrid" ships="{ model.ships }" selectedShip="{ model.selectedShip }" select="model.selectedShip = event.target.selectedShip" /> <ships:shipDetails shipSelected="{model.selectedShip}" /> </mx:VDividedBox> </mx:Canvas> Now the Grid: <mx:DataGrid xmlns:mx="http://www.adobe.com/2006/mxml" width="978" height="190" creationComplete="getShips()" dataProvider="{ ships }" change="updateSelectedShip( event );" dragEnabled="true" selectedIndex="0"> <mx:Metadata> [Event("select")] </mx:Metadata> <mx:Script> <![CDATA[ import mx.controls.dataGridClasses.DataGridColumn; import com.cardinal.flex.cruise.vo.ShipVO; import mx.collections.*; import com.cardinal.flex.cruise.event.GetShipsEvent; import com.adobe.cairngorm.control.CairngormEventDispatcher; import com.adobe.cairngorm.control.CairngormEvent; import com.cardinal.flex.cruise.model.CruiseModelLocator; public static var SELECT_EVENT : String = "select"; [Bindable] public var model : CruiseModelLocator = CruiseModelLocator.getInstance(); [Bindable] public var ships : ArrayCollection; [Bindable] public var selectedShip : ShipVO; public function getShips():void { var event : GetShipsEvent = new GetShipsEvent(GetShipsEvent.EVENT_FIND_SHIPS); CairngormEventDispatcher.getInstance().dispatchEvent( event ); } private function calcPortCountry(item:Object, col:DataGridColumn) : String { return item.port.country; } public function updateSelectedShip( event : Object ) : void { selectedShip = event.target.selectedShip; CairngormEventDispatcher.getInstance().dispatchEvent( new CairngormEvent( SELECT_EVENT ) ); } ]]> </mx:Script> <mx:columns> <mx:DataGridColumn headerText="Name" dataField="name"/> <mx:DataGridColumn headerText="Class" dataField="clazz"/> <mx:DataGridColumn headerText="Comments" dataField="comments"/> <mx:DataGridColumn headerText="Port Country" labelFunction="calcPortCountry" /> </mx:columns> </mx:DataGrid> And here is the details component: <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="978" height="227"> <mx:Script> <![CDATA[ import com.cardinal.flex.cruise.vo.ShipVO; [Bindable] public var shipSelected : ShipVO; ]]> </mx:Script> <mx:Image source="@Embed(source='../../../../../../../assets/empressboat/empress.boatphoto.jpg')" autoLoad="true" x="10" y="10"/> <mx:Image source="@Embed(source='../../../../../../../assets/grandeurboat/gr.bigroom.photo.jpg')" autoLoad="true" height="147" width="224" right="10" top="7"/> <mx:Label x="197" y="10" text="{shipSelected.name}" fontWeight="bold" fontSize="15" color="#359DDA"/> <mx:Label x="197" y="94" text="Ammenities:" fontWeight="bold"/> <mx:Label x="197" y="111" width="281" height="56" text="{shipSelected.comments}"/> <mx:Label x="502" y="5" text="{shipSelected.name} Featured Room:" fontSize="15" fontWeight="bold" color="#359DDA"/> <mx:Label x="502" y="26" text="Name: Big Nice Comfy Room" fontWeight="bold"/> <mx:Label x="502" y="43" text="Cost Per Night: $1500.00" fontWeight="bold"/> <mx:Label x="502" y="60" text="Num of Beds: 1" fontWeight="bold"/> <mx:Label x="502" y="77" text="Num of Baths: 1" fontWeight="bold"/> <mx:Label x="502" y="94" text="Ammenities:" fontWeight="bold"/> <mx:Label x="502" y="111" text="Personal Ocean Deck View bay window." width="214"/> <mx:Label x="373" y="10" id="port"/> <mx:Label x="197" y="36" text="Class:"/> <mx:Label x="240" y="36" text="{shipSelected.clazz}"/> <mx:Label x="197" y="60" text="Home Port Name:"/> <mx:Label x="307" y="60" text="{shipSelected.port.name}"/> <mx:Label x="200" y="77" text="Home Port Country:"/> <mx:Label x="326" y="77" text="{shipSelected.port.country}"/> </mx:Panel> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

