Solved

Accessing combobox dataprovider within datagrid itemrenderer

Posted on 2007-11-13
12
10,315 Views
Last Modified: 2011-06-10
Hi,

I have a datagrid that has a combobox as an itemrenderer.  I need to populate the comboxbox's dataprovider not using binding so I need access to the actual property of the combobox.  What would this be?

//Need to assign arrDispositions to below combobox.
      private function handlePartiesCourtDisp(event:ResultEvent):void{
            var arrDispositions:ArrayCollection;
            arrDispositions = new ArrayCollection(event.result as Array);
                                                                  
      }

<mx:DataGrid id="dgDaily" width="100%" height="100%"
      wordWrap="true"
      dataProvider="{parentApplication.partiesCourt}">

<mx:DataGridColumn id="dgcDisposition" headerText="Disposition" dataField="DISPOSITION" width="114"
                        >
                        <mx:itemRenderer>
                              <mx:Component className="Disps2">
                                    <mx:ComboBox
                                          change="outerDocument.updateDispositions(this.selectedItem)"
                                          />
                              </mx:Component>
                        </mx:itemRenderer>

</mx:DataGrid>
0
Comment
Question by:blue44
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
12 Comments
 
LVL 23

Expert Comment

by:Siva Prasanna Kumar
ID: 20277884
See if this can help

http://thanksmister.com/?p=24
0
 
LVL 19

Expert Comment

by:Gary Benade
ID: 20317969
There are ways to do this but normally only from an event handler, item editors/renderers are reused so there is no way to guarantee that a editor/renderer for a given row will still be valid unless its the current row. Do you want to change the contents of the combobox for each row? If so there is an easier way to do it with binding and a custom combobox component, let me know if you want an example.
0
Retailers - Is your network secure?

With the prevalence of social media & networking tools, for retailers, reputation is critical. Have you considered the impact your network security could have in your customer's experience? Learn more in our Retail Security Resource Kit Today!

 

Author Comment

by:blue44
ID: 20321721
hobbit72...thanks so much for the reply.  This has been driving me nuts.  I do need to change the contents of the combobox for each row.  In short, this is what I'm trying to accomplish:

1) User makes an update in a form within the application that in turn populates the datagrid with a new row.  This new row has a combobox with various values.

2) User can then select a different combo box value and each change updates the backend database and the datagrid.

I have simplified my code so that I have one array of combo-box elements and a combo-box item renderer.  Every update to the grid pushes the new value into the array.  It works except that each new row takes on the value of the last updated array (which makes sense).  My code is below.  The column where the combo box lies is 'dgcDisposition'.

Thanks again for all your help!

blue44
<?xml version="1.0" encoding="utf-8"?>
<c:MaxRestorePanel xmlns:mx="http://www.adobe.com/2006/mxml"
	height="25%" width="100%" title="Cases to Court" xmlns:c="components.*">	
	
	<mx:Script>
		<![CDATA[
			import mx.collections.ArrayCollection;
			import mx.core.IFlexDisplayObject;
			import mx.managers.PopUpManager;
			import mx.controls.Alert;
  		    import mx.containers.TitleWindow;
  		    import mx.events.ListEvent;
  		    import mx.rpc.events.*;
			import mx.rpc.events.ResultEvent;
  		    	
  		    [Bindable]
  		    public var arrDispositions:ArrayCollection;	
  		    
  		    [Bindable]
  		    public var arrPartiesCourt:Array = [ {label:" ", data:" "},
  		    									 {label:"Ct-Off Calendar", data:"Ct-Off Calendar"},
  		    									 {label:"Ct-Default", data:"Ct-Default"},
  		    									 {label:"Ct-Cont for review", data:"Ct-Cont for review"},
  		    									 {label:"Ct-OAH", data:"Ct-OAH"},
  		    									 {label:"Ct-Default", data:"Ct-Default"},
  		    									 {label:"Ct-Cont for addl info from DCSS", data:"Ct-Cont for addl info from DCSS"},
  		    									 {label:"Ct-Cont at request of party", data:"Ct-Cont at request of party"},
  		    									 {label:"Ct-Partial Stip/OAH", data:"Ct-Partial Stip/OAH"},
  		    									 {label:"Ct-Partial Stip/Cont for info from party", data:"Ct-Partial Stip/Cont for info from party"},
  		    									 {label:"Ct-Partial Stip/Cont for DCSS follow up", data:"Ct-Partial Stip/Cont for DCSS follow up"},
  		    									 {label:"Ct-Mandatory to Ct", data:"Ct-Mandatory to Ct"},	
			]
  		    		    					
			public function showNotesWindow(event:Event):void{
			 	var titleWindowInstance:NotesWindow = NotesWindow(PopUpManager.createPopUp(this,NotesWindow,false)); 
			  	titleWindowInstance.title = "Check-In";
			  	titleWindowInstance.width = 570;
			  	titleWindowInstance.height = 750;
		 		titleWindowInstance.intDcssCaseNo = dgDaily.selectedItem.DCSSCASENO;
		 		titleWindowInstance.stCourtOrder = dgDaily.selectedItem.COURTORDER;
			 	titleWindowInstance.stRespondentName = dgDaily.selectedItem.RESPONDENTNAME;
				titleWindowInstance.intCalendarSupportSeq = dgDaily.selectedItem.CALENDARSUPPORTSEQ;
				titleWindowInstance.stHearingType = dgDaily.selectedItem.HEARINGCATEGORY;
				titleWindowInstance.stDcssRep = dgDaily.selectedItem.DCSSREP;			 	
			 }
			  
		 	public function getDispositions():void{
				var queryArray:Array = new Array();
				queryArray[0] = parentApplication.cFilter.dateBegin.text;
				queryArray[1] = parentApplication.cFilter.cbxCalendar.value;
				queryArray[2] = parentApplication.cFilter.cbxDepartment.value;
				queryArray[3] = "PartiesCourt";
				roPartiesCourtDisp.getDispositions(queryArray);
			}
			 
			private function handlePartiesCourtDisp(event:ResultEvent):void{
				/* for(var i:int;i<event.message.body.length;i++){
					var resultArray:Array = new Array();
					
				} */		
				arrPartiesCourt.push(event.message.body[0]);
				//arrDispositions = new ArrayCollection(event.result as Array);
				//components.Disps.cbDisps.dataprovider = arrDispositions;
				//dgcDisposition.dataprovider = arrDispositions;
				//Disps.di.dataprovider = arrDispositions;
				//assignedReps.addItemAt(" ",0);								
			}
			
			public function updateDispositions(data:Object):void{
				//Alert.show(data.toString());
				//Alert.show(dgDaily.selectedItem.CALENDARSUPPORTSEQ);
				var queryArray:Array = new Array();
				queryArray[0] = dgDaily.selectedItem.CALENDARSUPPORTSEQ;
				queryArray[1] = data.data;
				queryArray[2] = parentApplication.username;
				roUpdateDisposition.updateDisposition(queryArray);
			}
					
		]]>
	</mx:Script>
	
	<mx:RemoteObject id="roPartiesCourtDisp" destination="ColdFusion" endpoint="{parentApplication.roEndPoint}"
				source="components.CalendarSupport" 
				showBusyCursor="true" fault="parentApplication.faultHandler(event)" result="handlePartiesCourtDisp(event)" /> 
				
	<mx:RemoteObject id="roUpdateDisposition" destination="ColdFusion" endpoint="{parentApplication.roEndPoint}"
				source="components.CalendarSupport" result="handlePartiesCourtDisp(event)"
				showBusyCursor="true" fault="parentApplication.faultHandler(event)" /> 
			
							
	<mx:DataGrid id="dgDaily" width="100%" height="100%"
	wordWrap="true" 
	dataProvider="{parentApplication.partiesCourt}">
		<mx:columns>
			<!--<mx:DataGridColumn headerText="DCSS Case" dataField="DCSSCASENO" width="90"/> -->
			<mx:DataGridColumn id="dgCalendarSupportSeq" dataField="CALENDARSUPPORTSEQ" visible="false" width="0" />
			<mx:DataGridColumn headerText=" " dataField="CASETYPE" visible="true" width="40" 
					itemRenderer="components.CaseTypeImage"/>
			<mx:DataGridColumn headerText="DCSS Case" dataField="DCSSCASENO" id="dgcDcssCase" width="90">
					<mx:itemRenderer>
						<mx:Component>
							<mx:LinkButton label="{data.DCSSCASENO}" color="#336699" click="outerDocument.showNotesWindow(event)" >
							</mx:LinkButton>
						</mx:Component>
					</mx:itemRenderer>
			</mx:DataGridColumn>
			<mx:DataGridColumn headerText="Court Order" dataField="COURTORDER" width="70"/>
			<mx:DataGridColumn headerText="Respondent" dataField="RESPONDENTNAME" width="115"/>
			<mx:DataGridColumn headerText="Hearing Type" dataField="HEARINGCATEGORY" width="60"/>
			<mx:DataGridColumn headerText="CP" dataField="CPREPRESENTATION" width="60"/>
			<mx:DataGridColumn headerText="CP Check-In" dataField="CPCHECKINTIME" width="85"/>
			<mx:DataGridColumn headerText="NCP" dataField="NCPREPRESENTATION" width="60"/>
			<mx:DataGridColumn headerText="NCP Check-In" dataField="NCPCHECKINTIME" width="85"/>
			<mx:DataGridColumn id="dgcDisposition" headerText="Disposition" dataField="DISPOSITION" width="114"
				>
				<mx:itemRenderer>
					<mx:Component className="Disps">
						<mx:ComboBox dataProvider="{outerDocument.arrPartiesCourt}"
							change="outerDocument.updateDispositions(this.selectedItem)"/>
					</mx:Component>
				</mx:itemRenderer>
			</mx:DataGridColumn>
			<mx:DataGridColumn headerText="DCSS Rep" dataField="DCSSREP" width="60"/>
		</mx:columns>
												
	</mx:DataGrid>							
 
								
</c:MaxRestorePanel>

Open in new window

0
 
LVL 19

Expert Comment

by:Gary Benade
ID: 20327274
You need to create a custom component based on ComboBox to get this to work. I have attached a working example that I coded a while back, since there are almost no complete examples that use an arraycollection as a dataprovider on the web at the moment it should help a lot.

Regards
Gary
<!--GridComboTest.mxml -->
<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
	xmlns:mx="http://www.adobe.com/2006/mxml" 
	layout="absolute" 
	xmlns:local="*">
	<mx:Script>
		<![CDATA[
			import mx.events.DropdownEvent;
			import mx.controls.Label;
			import mx.events.DataGridEvent;
			import mx.events.DataGridEventReason;
			import mx.controls.ComboBox;
						
            private function processData(event:DataGridEvent):void 
            {
                if (event.reason == DataGridEventReason.CANCELLED)
                {
                    return;
                }           
                if(event.dataField == "countryLink")
                {
                    event.preventDefault();
					var gcb:GridComboBox = dg.itemEditorInstance as GridComboBox;
                    dg.editedItemRenderer.data.countryLink = gcb.data.countryLink;
                    dg.destroyItemEditor();
                   	dg.dataProvider.itemUpdated(event.itemRenderer.data);					
                }
            }  	
			private function resolveLinkToCountry(item:Object, column:DataGridColumn):String
			{
				for each( var dp:Object in comboData)
				{
					if( dp.link == item.countryLink)
						return dp.country;
				}
				return "";				
			}
		]]>
	</mx:Script>
	<mx:ArrayCollection id="comboData">
		<mx:Object country="South Africa" link="1"/>
		<mx:Object country="Germany" link="2"/>
		<mx:Object country="USA" link="3"/>
		<mx:Object country="Brazil" link="4"/>			
	</mx:ArrayCollection>
	<mx:Array id="gridData">
		<mx:Object city="Johannesburg" countryLink="1"/>
		<mx:Object city="Vereeniging" countryLink="1"/>
		<mx:Object city="Seattle" countryLink="3"/>
		<mx:Object city="New York" countryLink="3"/>
	</mx:Array>
	<mx:DataGrid id="dg" x="10" y="10" dataProvider="{gridData}" editable="true" itemEditEnd="processData(event)">
		<mx:columns>
	        <mx:DataGridColumn width="130" dataField="city" headerText="City" editable="false" >
	        </mx:DataGridColumn>
	        <mx:DataGridColumn width="130" dataField="countryLink" headerText="Country" labelFunction="{resolveLinkToCountry}">
                <mx:itemEditor>
                    <mx:Component>
	                   	<local:GridComboBox dataProvider="{outerDocument.comboData}" labelField="country" lookupField="link" close="event.currentTarget.dispatchEvent(new KeyboardEvent( KeyboardEvent.KEY_DOWN,true,false,flash.ui.Keyboard.ENTER))"/>
                    </mx:Component>
                </mx:itemEditor>	        	        
	        </mx:DataGridColumn>                
	        <mx:DataGridColumn width="130" dataField="countryLink" headerText="Country Link" editable="false">
	        </mx:DataGridColumn>
		</mx:columns>
	</mx:DataGrid>	
</mx:Application>
 
<!--GridComboBox.mxml -->
<?xml version="1.0" encoding="utf-8"?>
<mx:ComboBox 
	xmlns:mx="http://www.adobe.com/2006/mxml" 
	dataChange="setSelected()" 
	change="onSelectionChange(event)">
	<mx:Script>
		<![CDATA[
			import mx.events.ListEvent;
			import mx.controls.dataGridClasses.DataGridListData;
		
			private var _ownerData:Object;
			private var _lookupField:String = "value";
			
			public function set lookupField(value:String):void
            {
                if(value)
                {                    
                    _lookupField = value;
                    setSelected();
                }
            }			
			override public function set data(value:Object):void
            {
                if(value)
                {                    
                    _ownerData = value;
                    setSelected();
                }
            }
            override public function get data():Object
            {
                return _ownerData;
            }            
            private function setSelected():void 
            {
            	if( dataProvider && _ownerData)
            	{
	                var col:DataGridListData = DataGridListData(listData);
					for each( var dp:Object in dataProvider) 
					{
						if( dp[_lookupField] == _ownerData[col.dataField])
						{
							selectedItem = dp;
							return;		
						}
					}
            	}
           		selectedItem = null;
            }
			private function onSelectionChange(e:ListEvent):void
            {
                if(selectedItem && _ownerData){
                    
                    var col:DataGridListData = DataGridListData(listData);
                    _ownerData[col.dataField] = selectedItem[_lookupField];
                }
            }          			
		]]>
	</mx:Script>	
</mx:ComboBox>

Open in new window

0
 
LVL 19

Expert Comment

by:Gary Benade
ID: 20327360
I havent checked this through properly, but the essence of what you will need to do is:
//>> at line 116
                <mx:itemEditor>
                    <mx:Component>
	                   	<local:GridComboBox dataProvider="{outerDocument.comboData}" labelField="country" lookupField="link" close="event.currentTarget.dispatchEvent(new KeyboardEvent( KeyboardEvent.KEY_DOWN,true,false,flash.ui.Keyboard.ENTER))"/>
                    </mx:Component>
                </mx:itemEditor>	
 
//>> at line 91
<mx:DataGrid id="dgDaily" width="100%" height="100%"
	wordWrap="true" 
	dataProvider="{parentApplication.partiesCourt}" itemEditEnd="processData(event)">
 
 
//>> at line 70, add to Script
private function processData(event:DataGridEvent):void 
            {
                if (event.reason == DataGridEventReason.CANCELLED)
                {
                    return;
                }           
                if(event.dataField == "data")
                {
                    event.preventDefault();
					var gcb:GridComboBox = dg.itemEditorInstance as GridComboBox;
                    dg.editedItemRenderer.data.data = gcb.data.data;
                    dg.destroyItemEditor();
                   	dg.dataProvider.itemUpdated(event.itemRenderer.data);					
                }
            } 

Open in new window

0
 
LVL 19

Expert Comment

by:Gary Benade
ID: 20337463
Any progress?
0
 

Author Comment

by:blue44
ID: 20340885
Hey Gary...sorry for not getting back to you.  Thanks so much for the code.   I'm actually out of town and won't get to this until Monday.  I'll let you know if this does the trick.

Have a great weekend!
-Darius
0
 

Author Comment

by:blue44
ID: 20354356
Hey Gary,

I got around to implementing your code but seem to still have a problem with the updating of individual rows.  Basically, everytime I add a new row to the gird, it picks up the last selected item of the previous row instead of defaulting to the first array element of comboData (in this case a blank record).  Do you see a way around it.  It could be that I'm just missing something in implementing your code...:-)

I used your GridComboBox.mxml verbatim and have attached my updated code below.  

Many thanks,
Darius
<?xml version="1.0" encoding="utf-8"?>
<c:MaxRestorePanel xmlns:mx="http://www.adobe.com/2006/mxml"
	height="25%" width="100%" title="Cases to Court" xmlns:c="components.*">	
	
	<mx:Script>
		<![CDATA[
			import mx.events.DataGridEvent;
			import mx.collections.ArrayCollection;
			import mx.core.IFlexDisplayObject;
			import mx.managers.PopUpManager;
			import mx.controls.Alert;
  		    import mx.containers.TitleWindow;
  		    import mx.events.ListEvent;
  		    import mx.rpc.events.*;
			import mx.rpc.events.ResultEvent;
			import mx.events.DropdownEvent;
			import mx.controls.Label;
			import mx.events.DataGridEvent;
			import mx.events.DataGridEventReason;
			import mx.controls.ComboBox;
  		    	
  		    [Bindable]
  		    public var arrDispositions:ArrayCollection;	
  		    
  		    [Bindable]
  		    public var arrPartiesCourt:Array = [ {label:" ", data:" "},
  		    									 {label:"Ct-Off Calendar", data:"Ct-Off Calendar"},
  		    									 {label:"Ct-Default", data:"Ct-Default"},
  		    									 {label:"Ct-Cont for review", data:"Ct-Cont for review"},
  		    									 {label:"Ct-OAH", data:"Ct-OAH"},
  		    									 {label:"Ct-Default", data:"Ct-Default"},
  		    									 {label:"Ct-Cont for addl info from DCSS", data:"Ct-Cont for addl info from DCSS"},
  		    									 {label:"Ct-Cont at request of party", data:"Ct-Cont at request of party"},
  		    									 {label:"Ct-Partial Stip/OAH", data:"Ct-Partial Stip/OAH"},
  		    									 {label:"Ct-Partial Stip/Cont for info from party", data:"Ct-Partial Stip/Cont for info from party"},
  		    									 {label:"Ct-Partial Stip/Cont for DCSS follow up", data:"Ct-Partial Stip/Cont for DCSS follow up"},
  		    									 {label:"Ct-Mandatory to Ct", data:"Ct-Mandatory to Ct"},	
			]
  		    		    					
			public function showNotesWindow(event:Event):void{
			 	var titleWindowInstance:NotesWindow = NotesWindow(PopUpManager.createPopUp(this,NotesWindow,false)); 
			  	titleWindowInstance.title = "Check-In";
			  	titleWindowInstance.width = 570;
			  	titleWindowInstance.height = 750;
		 		titleWindowInstance.intDcssCaseNo = dgDaily.selectedItem.DCSSCASENO;
		 		titleWindowInstance.stCourtOrder = dgDaily.selectedItem.COURTORDER;
			 	titleWindowInstance.stRespondentName = dgDaily.selectedItem.RESPONDENTNAME;
				titleWindowInstance.intCalendarSupportSeq = dgDaily.selectedItem.CALENDARSUPPORTSEQ;
				titleWindowInstance.stHearingType = dgDaily.selectedItem.HEARINGCATEGORY;
				titleWindowInstance.stDcssRep = dgDaily.selectedItem.DCSSREP;			 	
			 }
			  
		 	public function getDispositions():void{
				var queryArray:Array = new Array();
				queryArray[0] = parentApplication.cFilter.dateBegin.text;
				queryArray[1] = parentApplication.cFilter.cbxCalendar.value;
				queryArray[2] = parentApplication.cFilter.cbxDepartment.value;
				queryArray[3] = "PartiesCourt";
				roPartiesCourtDisp.getDispositions(queryArray);
			}
			 
			private function handlePartiesCourtDisp(event:ResultEvent):void{
				/* for(var i:int;i<event.message.body.length;i++){
					var resultArray:Array = new Array();
					
				} */		
				//arrPartiesCourt.push(event.message.body[0]);
				//arrDispositions = new ArrayCollection(event.result as Array);
				//components.Disps.cbDisps.dataprovider = arrDispositions;
				//dgcDisposition.dataprovider = arrDispositions;
				//Disps.di.dataprovider = arrDispositions;
				//assignedReps.addItemAt(" ",0);								
			}
			
			public function updateDispositions(data:Object):void{
				//Alert.show(data.toString());
				//Alert.show(dgDaily.selectedItem.CALENDARSUPPORTSEQ);
				var queryArray:Array = new Array();
				queryArray[0] = dgDaily.selectedItem.CALENDARSUPPORTSEQ;
				//queryArray[1] = data.data;
				queryArray[1] = data.link;
				queryArray[2] = parentApplication.username;
				roUpdateDisposition.updateDisposition(queryArray);
			}
			
			private function processData(event:DataGridEvent):void 
            {
                if (event.reason == DataGridEventReason.CANCELLED)
                {
                    return;
                }           
                if(event.dataField == "data")
                {
                    event.preventDefault();
					var gcb:GridComboBox = dgDaily.itemEditorInstance as GridComboBox;
                    dgDaily.editedItemRenderer.data.data = gcb.data.data;
                    dgDaily.destroyItemEditor();
                   	dgDaily.dataProvider.itemUpdated(event.itemRenderer.data);
                   	Alert.show("meow");					
                }
            } 
					
		]]>
	</mx:Script>
	
	<mx:ArrayCollection id="comboData">
		<mx:Object disposition=" " link=" "/>
		<mx:Object disposition="Ct-Off Calendar" link="Ct-Off Calendar"/>
		<mx:Object disposition="Ct-Default" link="Ct-Default"/>
		<mx:Object disposition="Ct-Cont for review" link="Ct-Cont for review"/>
		<mx:Object disposition="Ct-OAH" link="Ct-OAH"/>
		<mx:Object disposition="Ct-Default" link="Ct-Default"/>
		<mx:Object disposition="Ct-Cont for addl info from DCSS" link="Ct-Cont for addl info from DCSS"/>
		<mx:Object disposition="Ct-Cont at request of party" link="Ct-Cont at request of party"/>
		<mx:Object disposition="Ct-Partial Stip/OAH" link="Ct-Partial Stip/OAH"/>
		<mx:Object disposition="Ct-Partial Stip/Cont for info from party" link="Ct-Partial Stip/Cont for info from party"/>
		<mx:Object disposition="Ct-Partial Stip/Cont for DCSS follow up" link="Ct-Partial Stip/Cont for DCSS follow up"/>
		<mx:Object disposition="Ct-Mandatory to Ct" link="Ct-Mandatory to Ct"/>			
	</mx:ArrayCollection>
	
	<mx:RemoteObject id="roPartiesCourtDisp" destination="ColdFusion" endpoint="{parentApplication.roEndPoint}"
				source="components.CalendarSupport" 
				showBusyCursor="true" fault="parentApplication.faultHandler(event)" result="handlePartiesCourtDisp(event)" /> 
				
	<mx:RemoteObject id="roUpdateDisposition" destination="ColdFusion" endpoint="{parentApplication.roEndPoint}"
				source="components.CalendarSupport" result="handlePartiesCourtDisp(event)"
				showBusyCursor="true" fault="parentApplication.faultHandler(event)" /> 
			
							
	<mx:DataGrid id="dgDaily" width="100%" height="100%"
	wordWrap="true" 
	dataProvider="{parentApplication.partiesCourt}" itemEditEnd="processData(event)">
		<mx:columns>
			<!--<mx:DataGridColumn headerText="DCSS Case" dataField="DCSSCASENO" width="90"/> -->
			<mx:DataGridColumn id="dgCalendarSupportSeq" dataField="CALENDARSUPPORTSEQ" visible="false" width="0" />
			<mx:DataGridColumn headerText=" " dataField="CASETYPE" visible="true" width="40" 
					itemRenderer="components.CaseTypeImage"/>
			<mx:DataGridColumn headerText="DCSS Case" dataField="DCSSCASENO" id="dgcDcssCase" width="90">
					<mx:itemRenderer>
						<mx:Component>
							<mx:LinkButton label="{data.DCSSCASENO}" color="#336699" click="outerDocument.showNotesWindow(event)" >
							</mx:LinkButton>
						</mx:Component>
					</mx:itemRenderer>
			</mx:DataGridColumn>
			<mx:DataGridColumn headerText="Court Order" dataField="COURTORDER" width="70"/>
			<mx:DataGridColumn headerText="Respondent" dataField="RESPONDENTNAME" width="115"/>
			<mx:DataGridColumn headerText="Hearing Type" dataField="HEARINGCATEGORY" width="60"/>
			<mx:DataGridColumn headerText="CP" dataField="CPREPRESENTATION" width="60"/>
			<mx:DataGridColumn headerText="CP Check-In" dataField="CPCHECKINTIME" width="85"/>
			<mx:DataGridColumn headerText="NCP" dataField="NCPREPRESENTATION" width="60"/>
			<mx:DataGridColumn headerText="NCP Check-In" dataField="NCPCHECKINTIME" width="85"/>
			<mx:DataGridColumn id="dgcDisposition" headerText="Disposition" dataField="DISPOSITION" width="114">
				<mx:itemRenderer>
					<mx:Component className="Disps">
						<!--<mx:ComboBox dataProvider="{outerDocument.arrPartiesCourt}"
							change="outerDocument.updateDispositions(this.selectedItem)"/> -->
							<c:GridComboBox dataProvider="{outerDocument.comboData}"
							lookupField="link" labelField="disposition"
							close="event.currentTarget.dispatchEvent(new KeyboardEvent( KeyboardEvent.KEY_DOWN,true,false,flash.ui.Keyboard.ENTER))"
							change="outerDocument.updateDispositions(this.selectedItem)"/>
					</mx:Component>
				</mx:itemRenderer>
			</mx:DataGridColumn>
			<mx:DataGridColumn headerText="DCSS Rep" dataField="DCSSREP" width="60"/>
		</mx:columns>
												
	</mx:DataGrid>							
 
								
</c:MaxRestorePanel>

Open in new window

0
 
LVL 19

Expert Comment

by:Gary Benade
ID: 20366670
Try moving line 161 to 99
0
 

Author Comment

by:blue44
ID: 20370643
Thanks, Gary.  That helped but there still seems to be one small problem.  When a new record is added to the row, it still defaults to the last array element that was selected for the previous row.  Is there anyway to generate a new array on the initialization of the new row so that it defaults to a blank record?

Many thanks,
Darius
<?xml version="1.0" encoding="utf-8"?>
<c:MaxRestorePanel xmlns:mx="http://www.adobe.com/2006/mxml"
	height="25%" width="100%" title="Cases to Court" xmlns:c="components.*">	
	
	<mx:Script>
		<![CDATA[
			import mx.events.DataGridEvent;
			import mx.collections.ArrayCollection;
			import mx.core.IFlexDisplayObject;
			import mx.managers.PopUpManager;
			import mx.controls.Alert;
  		    import mx.containers.TitleWindow;
  		    import mx.events.ListEvent;
  		    import mx.rpc.events.*;
			import mx.rpc.events.ResultEvent;
			import mx.events.DropdownEvent;
			import mx.controls.Label;
			import mx.events.DataGridEvent;
			import mx.events.DataGridEventReason;
			import mx.controls.ComboBox;
  		    	
  		    [Bindable]
  		    public var arrDispositions:ArrayCollection;	
  		    
  		    [Bindable]
  		    public var arrPartiesCourt:Array = [ {label:" ", data:" "},
  		    									 {label:"Ct-Off Calendar", data:"Ct-Off Calendar"},
  		    									 {label:"Ct-Default", data:"Ct-Default"},
  		    									 {label:"Ct-Cont for review", data:"Ct-Cont for review"},
  		    									 {label:"Ct-OAH", data:"Ct-OAH"},
  		    									 {label:"Ct-Default", data:"Ct-Default"},
  		    									 {label:"Ct-Cont for addl info from DCSS", data:"Ct-Cont for addl info from DCSS"},
  		    									 {label:"Ct-Cont at request of party", data:"Ct-Cont at request of party"},
  		    									 {label:"Ct-Partial Stip/OAH", data:"Ct-Partial Stip/OAH"},
  		    									 {label:"Ct-Partial Stip/Cont for info from party", data:"Ct-Partial Stip/Cont for info from party"},
  		    									 {label:"Ct-Partial Stip/Cont for DCSS follow up", data:"Ct-Partial Stip/Cont for DCSS follow up"},
  		    									 {label:"Ct-Mandatory to Ct", data:"Ct-Mandatory to Ct"},	
			]
  		    		    					
			public function showNotesWindow(event:Event):void{
			 	var titleWindowInstance:NotesWindow = NotesWindow(PopUpManager.createPopUp(this,NotesWindow,false)); 
			  	titleWindowInstance.title = "Check-In";
			  	titleWindowInstance.width = 570;
			  	titleWindowInstance.height = 750;
		 		titleWindowInstance.intDcssCaseNo = dgDaily.selectedItem.DCSSCASENO;
		 		titleWindowInstance.stCourtOrder = dgDaily.selectedItem.COURTORDER;
			 	titleWindowInstance.stRespondentName = dgDaily.selectedItem.RESPONDENTNAME;
				titleWindowInstance.intCalendarSupportSeq = dgDaily.selectedItem.CALENDARSUPPORTSEQ;
				titleWindowInstance.stHearingType = dgDaily.selectedItem.HEARINGCATEGORY;
				titleWindowInstance.stDcssRep = dgDaily.selectedItem.DCSSREP;			 	
			 }
			  
		 	public function getDispositions():void{
				var queryArray:Array = new Array();
				queryArray[0] = parentApplication.cFilter.dateBegin.text;
				queryArray[1] = parentApplication.cFilter.cbxCalendar.value;
				queryArray[2] = parentApplication.cFilter.cbxDepartment.value;
				queryArray[3] = "PartiesCourt";
				roPartiesCourtDisp.getDispositions(queryArray);
			}
			 
			private function handlePartiesCourtDisp(event:ResultEvent):void{
				/* for(var i:int;i<event.message.body.length;i++){
					var resultArray:Array = new Array();
					
				} */		
				//arrPartiesCourt.push(event.message.body[0]);
				//arrDispositions = new ArrayCollection(event.result as Array);
				//components.Disps.cbDisps.dataprovider = arrDispositions;
				//dgcDisposition.dataprovider = arrDispositions;
				//Disps.di.dataprovider = arrDispositions;
				//assignedReps.addItemAt(" ",0);								
			}
			
			public function updateDispositions(data:Object):void{
				//Alert.show(data.toString());
				//Alert.show(dgDaily.selectedItem.CALENDARSUPPORTSEQ);
				var queryArray:Array = new Array();
				queryArray[0] = dgDaily.selectedItem.CALENDARSUPPORTSEQ;
				//queryArray[1] = data.data;
				queryArray[1] = data.link;
				queryArray[2] = parentApplication.username;
				roUpdateDisposition.updateDisposition(queryArray);
			}
			
			private function processData(event:DataGridEvent):void 
            {
                if (event.reason == DataGridEventReason.CANCELLED)
                {
                    return;
                }           
                if(event.dataField == "data")
                {
                    event.preventDefault();
					var gcb:GridComboBox = dgDaily.itemEditorInstance as GridComboBox;
                    dgDaily.editedItemRenderer.data.data = gcb.data.data;
                    dgDaily.destroyItemEditor();
                   	dgDaily.dataProvider.itemUpdated(event.itemRenderer.data);
                   	updateDispositions(event.itemRenderer.data);					
                }
            } 
					
		]]>
	</mx:Script>
	
	<mx:ArrayCollection id="comboData">
		<mx:Object disposition=" " link=" "/>
		<mx:Object disposition="Ct-Off Calendar" link="Ct-Off Calendar"/>
		<mx:Object disposition="Ct-Default" link="Ct-Default"/>
		<mx:Object disposition="Ct-Cont for review" link="Ct-Cont for review"/>
		<mx:Object disposition="Ct-OAH" link="Ct-OAH"/>
		<mx:Object disposition="Ct-Default" link="Ct-Default"/>
		<mx:Object disposition="Ct-Cont for addl info from DCSS" link="Ct-Cont for addl info from DCSS"/>
		<mx:Object disposition="Ct-Cont at request of party" link="Ct-Cont at request of party"/>
		<mx:Object disposition="Ct-Partial Stip/OAH" link="Ct-Partial Stip/OAH"/>
		<mx:Object disposition="Ct-Partial Stip/Cont for info from party" link="Ct-Partial Stip/Cont for info from party"/>
		<mx:Object disposition="Ct-Partial Stip/Cont for DCSS follow up" link="Ct-Partial Stip/Cont for DCSS follow up"/>
		<mx:Object disposition="Ct-Mandatory to Ct" link="Ct-Mandatory to Ct"/>			
	</mx:ArrayCollection>
	
	<mx:RemoteObject id="roPartiesCourtDisp" destination="ColdFusion" endpoint="{parentApplication.roEndPoint}"
				source="components.CalendarSupport" 
				showBusyCursor="true" fault="parentApplication.faultHandler(event)" result="handlePartiesCourtDisp(event)" /> 
				
	<mx:RemoteObject id="roUpdateDisposition" destination="ColdFusion" endpoint="{parentApplication.roEndPoint}"
				source="components.CalendarSupport" result="handlePartiesCourtDisp(event)"
				showBusyCursor="true" fault="parentApplication.faultHandler(event)" /> 
			
							
	<mx:DataGrid id="dgDaily" width="100%" height="100%"
	wordWrap="true" 
	dataProvider="{parentApplication.partiesCourt}" itemEditEnd="processData(event)">
		<mx:columns>
			<!--<mx:DataGridColumn headerText="DCSS Case" dataField="DCSSCASENO" width="90"/> -->
			<mx:DataGridColumn id="dgCalendarSupportSeq" dataField="CALENDARSUPPORTSEQ" visible="false" width="0" />
			<mx:DataGridColumn headerText=" " dataField="CASETYPE" visible="true" width="40" 
					itemRenderer="components.CaseTypeImage"/>
			<mx:DataGridColumn headerText="DCSS Case" dataField="DCSSCASENO" id="dgcDcssCase" width="90">
					<mx:itemRenderer>
						<mx:Component>
							<mx:LinkButton label="{data.DCSSCASENO}" color="#336699" click="outerDocument.showNotesWindow(event)" >
							</mx:LinkButton>
						</mx:Component>
					</mx:itemRenderer>
			</mx:DataGridColumn>
			<mx:DataGridColumn headerText="Court Order" dataField="COURTORDER" width="70"/>
			<mx:DataGridColumn headerText="Respondent" dataField="RESPONDENTNAME" width="115"/>
			<mx:DataGridColumn headerText="Hearing Type" dataField="HEARINGCATEGORY" width="60"/>
			<mx:DataGridColumn headerText="CP" dataField="CPREPRESENTATION" width="60"/>
			<mx:DataGridColumn headerText="CP Check-In" dataField="CPCHECKINTIME" width="85"/>
			<mx:DataGridColumn headerText="NCP" dataField="NCPREPRESENTATION" width="60"/>
			<mx:DataGridColumn headerText="NCP Check-In" dataField="NCPCHECKINTIME" width="85"/>
			<mx:DataGridColumn id="dgcDisposition" headerText="Disposition" dataField="DISPOSITION" width="114">
				<mx:itemRenderer>
					<mx:Component className="Disps">
						<!--<mx:ComboBox dataProvider="{outerDocument.arrPartiesCourt}"
							change="outerDocument.updateDispositions(this.selectedItem)"/> -->
							<c:GridComboBox dataProvider="{outerDocument.comboData}"
							lookupField="link" labelField="disposition"
							close="event.currentTarget.dispatchEvent(new KeyboardEvent( KeyboardEvent.KEY_DOWN,true,false,flash.ui.Keyboard.ENTER))"
							change="outerDocument.updateDispositions(this.selectedItem)"/>
					</mx:Component>
				</mx:itemRenderer>
			</mx:DataGridColumn>
			<mx:DataGridColumn headerText="DCSS Rep" dataField="DCSSREP" width="60"/>
		</mx:columns>
												
	</mx:DataGrid>							
 
								
</c:MaxRestorePanel>

Open in new window

0
 

Accepted Solution

by:
blue44 earned 0 total points
ID: 21405872
The solution for this is to not code this in Flex but return an object from CF as part of your query containing the list of different combo-box elements.
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question