Link to home
Start Free TrialLog in
Avatar of blue44
blue44Flag for United States of America

asked on

Accessing combobox dataprovider within datagrid itemrenderer

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>
Avatar of Siva Prasanna Kumar
Siva Prasanna Kumar
Flag of India image

See if this can help

http://thanksmister.com/?p=24
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.
Avatar of blue44

ASKER

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

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

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

Any progress?
Avatar of blue44

ASKER

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
Avatar of blue44

ASKER

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

Try moving line 161 to 99
Avatar of blue44

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of blue44
blue44
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial