Did you set editable=true on the DG?  If so, it should update the data
on itemEditEnd and not on change.

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of cmarkiewicz
Sent: Friday, November 23, 2007 1:43 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] ComboBox and DataGrid - set data() call causes
next ComboBox to collapse...

 


Hello. I have a DataGrid with a column of ComboBoxes. The behavior I'm
seeing is this:
1) I click on a ComboBox - it expands
2) I choose a value - it collapses
3) I click on a ComboBox in a different column
4) It expands - then immediately collapses

I have determined why it is happening, but I'm not sure how to make it
stop.

I have a separate mxml file where I define the ComboBox and I override
the
set data() method. The set data() method sets the value in the ComboBox
in
each row. The issues is that after I change a ComboBox in one row, set
data() is called on all rows - so as soon as I click on the second
ComboBox,
set data() is called (because I clicked away from the first ComboBox),
the
value is set in the second ComboBox - and it collapses. 

So, if I change the value in one ComboBox, click to some other cell,
then
click on the second ComboBox, it works fine (because set data() is
called
when i click to the other cell). So my questions is, how do I make this
work? Can I force the call to set data() as soon as the first ComboBox
collapses (my putting focus on another component temporarily?)? Or can I
make it bypass the set data() call from ComboBoxes which weren't
touched? 

Any help is greatly appreciated.

Code is below, if it helps...

Thanks
Chris

<?xml version="1.0" encoding="utf-8"?>
<!-- mxmlcomponents/TypeComboBoxRenderer.mxml -->
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " 
xmlns:lib="t3quote.*"
horizontalScrollPolicy="off" verticalScrollPolicy="off" 
>
<mx:Script>
<![CDATA[
import mx.messaging.channels.StreamingAMFChannel;
// Define a property for returning the new value to the cell.
[Bindable]
public var valueSelected:String;


override public function set data(value:Object):void
{
if(value != null)
{
super.data = value;
trace("set data...data.productCode:"+data.productCode);

//show the comboBox
if(value.nonPartFlag)
{
prodCodeChoices.visible=true;
prodCodeLabel.visible=false;
}
//hide the comboBox and show the label
else
{
prodCodeChoices.visible=false;
prodCodeLabel.visible=true;
}

var pcArr:Array = data.productCodeArray;
for (var j:int = 0; j < pcArr.length; j++)
{
var pctmp:String = pcArr[j];
if (pctmp == data.productCode)
{

trace("PrevIndex/NewIndex:"+prodCodeChoices.selectedIndex+"/"+j);

trace("PrevItem/NewItem:"+prodCodeChoices.selectedItem+"/"+data.productC
ode);
trace("Match found!!!:"+j+"/"+pctmp);
prodCodeChoices.selectedIndex = j;
}
}


} 
}


public function changeHandler(event:Event): void
{

trace("changeHandler...prodCodeChoices.selectedItem:"+prodCodeChoices.se
lectedItem);
valueSelected = String(prodCodeChoices.selectedItem);
} 
]]>
</mx:Script>

<mx:ComboBox id="prodCodeChoices" dataProvider="{data.productCodeArray}"
width="100%" 
change="changeHandler(event)"
creationComplete="prodCodeChoices.selectedItem=data.productCode"
/>
<!--
<lib:ComboBox id="prodCodeChoices"
dataProvider="{data.productCodeArray}"
width="100%" 
value="{data.productCode}" 
/>
--> 
<mx:Label id="prodCodeLabel" text="{data.productCode}" /> 

</mx:Canvas>

-- 
View this message in context:
http://www.nabble.com/ComboBox-and-DataGrid---set-data%28%29-call-causes
-next-ComboBox-to-collapse...-tf4841069.html#a13850434
<http://www.nabble.com/ComboBox-and-DataGrid---set-data%28%29-call-cause
s-next-ComboBox-to-collapse...-tf4841069.html#a13850434> 
Sent from the FlexCoders mailing list archive at Nabble.com.

 

Reply via email to