I have a tab navigator that has datagrids on each respective tab. The
datagrids are populated with a RemoteObject call and all works fine.
When the user clicks on a row (itemClick), the state changes and they
are brought to the details screen (for editing the content in a form).
The content grab is another RemoteObject call repective to the row
they clicked in the base state. So, the problem is, how do I make my
pickRow() function generic? It gathers the event goodies on the
rowClick and passes them to the RO call and passes the argument. But,
when I place the argument in the RemoteObject tag call, I need to
specifically reference the datagrid id. So this only works for one
data grid. How do I make it work for all the datagrids. I have wittled
the code down and placed it below.

TIA - Ben

        <mx:Script>
        <![CDATA[
                import mx.events.ListEvent;
                import mx.controls.Alert;
                import mx.rpc.events.FaultEvent;
                import mx.rpc.events.ResultEvent;
                import mx.collections.ArrayCollection;
                

            [Bindable]
                        private var myData:ArrayCollection;
                        [Bindable]
                        private var myRate:ArrayCollection;
                        [Bindable]
                        private var selected1:Number;
                        
                        private function queryHandler(event:ResultEvent):void
                        {
                                myData = event.result as ArrayCollection;
                        }
                        
                        private function 
queryRateHandler(event:ResultEvent):void
                        {
                                myRate = event.result as ArrayCollection;
                        }
                        
                        private function faultHandler(event:FaultEvent):void
                        {
                                Alert.show(event.fault.faultString, 
event.fault.faultCode);
                        }
                        
                        public function pickRow(event:ListEvent):void {
                                if (event.rowIndex > 0) {
                                        WS.GetInstructorDetail2.send();
                                        WS.ListContractorRates.send();
                                        currentState='detailTabs';
                                }       
                }
                
              ]]>
    </mx:Script>

<mx:RemoteObject id="WS"
                destination="ColdFusion"
                source="Compass.cfc.lsd"
                fault="faultHandler(event)">
                <mx:method name="GetInstructorDetail2" 
result="queryHandler(event)">
                        <mx:arguments>
                                
<InstructorId>{grid0.selectedItem.InstructorId}</InstructorId>
                        </mx:arguments>
                </mx:method>
                <mx:method name="ListContractorRates" 
result="queryRateHandler(event)">
                        <mx:arguments>
                                
<InstructorId>{grid0.selectedItem.InstructorId}</InstructorId>
                        </mx:arguments>
                </mx:method>
        </mx:RemoteObject>

<mx:DataGrid id="grid0" 
                                
dataProvider="{InstructorWS.ListActiveInstructors.lastResult}" 
                                itemClick="pickRow(event)" 
                                left="10" right="10" bottom="10" top="10" 
                                editable="false" 
                                enabled="true" 
                                sortableColumns="true" 
                                draggableColumns="false">
                                <mx:columns>
                                        <mx:DataGridColumn headerText="First 
Name" dataField="FirstName"
width="80"/>
                                        <mx:DataGridColumn headerText="Last 
Name" dataField="LastName"
width="80"/>
                                        <mx:DataGridColumn headerText="Email" 
dataField="Email"/>
                                        <mx:DataGridColumn headerText="Mobile" 
dataField="Mobile"
width="110"/>
                                        <mx:DataGridColumn headerText="Phone" 
dataField="Phone" width="110"/>
                                        <mx:DataGridColumn headerText="City" 
dataField="City" width="120"/>
                                        <mx:DataGridColumn headerText="State" 
dataField="State" width="40"/>
                                </mx:columns>
                        </mx:DataGrid>
                </mx:Canvas>
                <mx:Canvas label="Inactive Instructors" width="100%" 
height="100%"
id="canvas2">
                        <mx:DataGrid id="grid1" 
                                
dataProvider="{InstructorWS.ListInactiveInstructors.lastResult}" 
                                itemClick="pickRow(event)" 
                                left="10" right="10" bottom="10" top="10" 
                                editable="false" 
                                enabled="true" 
                                sortableColumns="true">
                                <mx:columns>
                                        <mx:DataGridColumn headerText="First 
Name" dataField="FirstName"
width="80"/>
                                        <mx:DataGridColumn headerText="Last 
Name" dataField="LastName"
width="80"/>
                                        <mx:DataGridColumn headerText="Email" 
dataField="Email"/>
                                        <mx:DataGridColumn headerText="Mobile" 
dataField="Mobile"
width="110"/>
                                        <mx:DataGridColumn headerText="Phone" 
dataField="Phone" width="110"/>
                                        <mx:DataGridColumn headerText="City" 
dataField="City" width="120"/>
                                        <mx:DataGridColumn headerText="State" 
dataField="State" width="40"/>
                                </mx:columns>
                        </mx:DataGrid>

Reply via email to