Renderers are recycled.   See my blog (blogs.adobe.com/aharui).  It is
almost never correct to use creationComplete in a renderer.  Setting
selectable="false" has also caused problems in the past.  Why do you
need to turn off selectable?

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: Sunday, April 27, 2008 9:32 AM
To: [email protected]
Subject: [flexcoders] Combobox And Datagrid

 

Hi Friends .. 

I am writting a simple code in which i have one datagrid with two
coloumns . in first coloumn iam using combobox as itemrenderer.
but this combobox is working abnormally when more and more item are
added to the grid or when scroll bar appears .
some one told me that this problem is solved in flex 3 but it is not .
i have compiled and run this code on three version of flex i.e Flex
2.0.1 ,Flex 2.0.1(Hot Fix Three),
and Flex Three.
But the application is behaving in different ways in both version . plz
help me to find the problem.
i am sharing my code with u plz run it and help me

<!-- Application.mxml -->
<?xml version="1.0"?>
<!-- dpcontrols/DataGridSpecifyColumns.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " creationComplete="{init()}" >

<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection; 
[Bindable]
public var gridDataProvider:ArrayCollection;
public function init():void
{
gridDataProvider = new ArrayCollection();
var del:Object = new Object();
del.name = '';
del.price = '';
gridDataProvider.addItem( del );
}
]]>
</mx:Script>
<mx:DataGrid id="grid" selectable="false"
dataProvider="{gridDataProvider}" >
<mx:columns>
<mx:DataGridColumn dataField="name" itemRenderer="ComboBoxRend"/>
<mx:DataGridColumn dataField="price" />

</mx:columns>
</mx:DataGrid>

</mx:Application>

<!-- ComboBoxRend.mxml-->
<?xml version="1.0" encoding="utf-8"?>
<mx:ComboBox dataProvider="{autoCompProvider}" labelField="name"
creationComplete="{init()}" xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " width="50" paddingRight="5"
paddingLeft="5" xmlns:fc="*" close="{closeEventHandler()}" >
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert; 
public function closeEventHandler():void
{
data.name = this.selectedLabel ;
data.price = this.selectedItem.price;
var emptyRow:Object = new Object();
emptyRow.name = '';
emptyRow.price = ''; 
ComboboxTest(this.parentApplication).gridDataProvider.addItem( emptyRow
);
}
[Bindable]
public var autoCompProvider:ArrayCollection;
public function init():void
{
autoCompProvider = new ArrayCollection();

var emptyRow:Object = new Object();
emptyRow.name = '';
emptyRow.price = ''; 
autoCompProvider.addItem( emptyRow );


var del:Object = new Object();
del.name = 'DELL';
del.price = 100;
autoCompProvider.addItem( del );

var msft:Object = new Object();
msft.name = 'MSFT';
msft.price = 200;
autoCompProvider.addItem( msft );

var mot:Object = new Object();
mot.name = 'MOT';
mot.price = 300;
autoCompProvider.addItem( mot );


var yahoo:Object = new Object();
yahoo.name = 'Yahoo';
yahoo.price = 400;
autoCompProvider.addItem( yahoo );



} 

]]>
</mx:Script>
</mx:ComboBox>

Thanks Parkash Arjan......

 

Reply via email to