Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
fastlife #1
passing selectedItem data from a component
I need help as I could not figure out my mistake ? I have main application page
and two components. The main page calls for the first component to display
data based on a selectedItem from a dataGrid of the main page and this works
very well. However, when I use the datagrid in the first component to pass the
property 'selectedDx' to the second component I can not get the dataObject to
be passed to the main page or second component. The property I am trying to
pass is 'selected Dx' in the below example Thank you from a newbie. HT
//main mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" width="815">
<mx:HTTPService id="dxListSrv" url="jspDiagnoses.jsp">
<mx:request>
<ptId>{dgPatients.selectedItem.patientID}</ptId>
</mx:request>
</mx:HTTPService>
<mx:Script>
<![CDATA[
var selectedPt;
var selectedDx:Object;
function selectPtData(event){
selectedPt=event.target.selectedItem;
dxListSrv.send();
}
]]>
</mx:Script>
<mx:Model id="patientModel" source="xmlPatients.xml"></mx:Model>
<mx:HBox>
<mx:DataGrid id="dgPatients" dataProvider="{patientModel.patient}"
change="selectPtData(event);" >
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="patientID"></mx:DataGridColumn>
<mx:DataGridColumn columnName="MRN"></mx:DataGridColumn>
<mx:DataGridColumn columnName="firstName"></mx:DataGridColumn>
<mx:DataGridColumn columnName="lastName"></mx:DataGridColumn>
</mx:Array>
</mx:columns>
</mx:DataGrid>
<local:PatientIdDetail xmlns:local="*" id="patientIdDetail" ptIdObject =
"{selectedPt}"/>
<mx:VBox>
<local:DiagnosesList id="dxList" xmlns:local="*" dxListObject =
"{dxListSrv.result.diagnoses.diagnosis}"
change="selectedDx=event.target.selectedItem" />
<mx:DataGrid dataProvider="{mx.utils.ArrayUtil.toArray(selected Dx)}">
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="description"></mx:DataGridColumn>
<mx:DataGridColumn columnName="diagnosisID"></mx:DataGridColumn>
</mx:Array>
</mx:columns>
</mx:DataGrid>
<local:RxList id="rxList" xmlns:local="*" rxListObject="{selectedDx}" />
</mx:VBox>
</mx:HBox>
<mx:Text text="{dgPatients.selectedItem.patientID}"/>
</mx:Application>
----------------------------- first component
------------------------------------------ DiagnosesList.mxml
------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.macromedia.com/2003/mxml" title="Diagnoses"
marginBottom="8" marginLeft="8" marginRight="4" marginTop="4">
<mx:Metadata>
[Event("change")]
</mx:Metadata>
<mx:Script>
var dxListObject:Object;
var selectedDx;
function selDx(event) {
selectedDx=event.target.selectedItem;
selectedDx.dispatchEvent({type:"change"});
}
</mx:Script>
<mx:DataGrid id="dxCmpList"
dataProvider="{mx.utils.ArrayUtil.toArray(dxListOb ject)}"
change="selDx(event);" >
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="description" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
<mx:DataGrid dataProvider="{mx.utils.ArrayUtil.toArray(selected Dx)}">
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="description" />
<mx:DataGridColumn columnName="diagnosisID" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
------------------------------------ swcond component RxList
-------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.macromedia.com/2003/mxml" title="Treatment"
marginBottom="8" marginLeft="8" marginRight="4" marginTop="4">
<mx:Script>
var rxListObject:Object;
</mx:Script>
<mx:Model id="testList">
<desc>{rxListObject.description}</desc>
<ptId>{rxListObject.patientID}</ptId>
</mx:Model>
<mx:Text text="{testList.desc}" />
<mx:DataGrid id="rxList" dataProvider="{mx.utils.ArrayUtil.toArray(testList )}">
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="desc" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
fastlife Guest
-
Passing CFGRID data to CFC
I'm trying to pass data in a cfgrid to an cfc using flash remoting. I'm passing it as myGrid.dataProvider, on the cfc side I have a CFARGUMENT of... -
passing an array to a web service using WS component
I am trying to send a bunch of form values to a webservice. The service accepts 7 parameters, 5 string values and 2 arrays. I am using the web... -
Passing parameters to a component
I'm trying to pass the dimensions of the main window to a component for positioning of a popup that it generates, but I keep getting the following... -
passing data through a database
Hi: I made one page that passes data through a form to another page. The destination (confirmation) page checks if the user filled the form or not... -
viewstate restores data but selectedItem is restored late
I have a Web Custom Control that has a checkBoxList control added to its control collection. This checkbox list control is initially populated... -
ntsiii #2
Re: passing selectedItem data from a component
I think maybe your change event target is the panel, which doesn't have a
selectedItem property.
Try this:
change="selectedDx=dxList.dxCmpList.selectedItem"
Or, in your datagrid in the component, build an event object with the
selectedItem in it and manually dispatch an event.
Tracy
ntsiii Guest
-
fastlife #3
Re: passing selectedItem data from a component
Thank you Tracy.
It worked right away.
Any useful hints where I can get a little more 'learining' done on these concepts.
Thank you again
HT
fastlife Guest



Reply With Quote

