Hi, my combobox cell renderer is derived from
http://www.richinternetapps.com/archives/000072.html I had to change my actionscript file a bit to make it work with my xml Thanx everyone for helping me find the solution. Regards Rajesh J // ActionScript Document import mx.controls.ComboBox; import mx.core.UIComponent import mx.controls.*; class ComboBoxCellRenderer extends UIComponent { var combo : ComboBox; var comboLabel : Label; var listOwner : Object; // the reference we receive to the list var getCellIndex : Function; // the function we receive from the list var getDataLabel : Function; // the function we receive from the list var selectedItem : Object; var changeFlag :Boolean; static var dataProvider; function ComboBoxCellRenderer() { } function createChildren(Void) : Void { super.createChildren(); createClassObject( Label, "comboLabel", 1, { styleName:this, owner:this } ); createClassObject( ComboBox, "combo", 2, { styleName:this, owner:this, selectable:true } ); combo.addEventListener( "change", this ); combo.addEventListener( "enter", this ); combo.dataProvider = ComboBoxCellRenderer.dataProvider; combo.setStyle( "backgroundColor", getStyle( "selectionColor" ) ); changeFlag = false; size(); } function size( Void ) : Void { combo.setSize( width, 20 ); comboLabel.setSize( width, 20 ); } function setValue( str : String, item : Object, selection : String ) : Void { if ( item == undefined ) { comboLabel.visible = false; combo.visible = false; return; } if ( selection == "normal" || selection == "highlighted" ) { if (changeFlag == false) for( var i = 0; i < combo.dataProvider.length; i++ ) { if( combo.dataProvider[i].data == item[ getDataLabel() ] ) { comboLabel.text = combo.dataProvider[i].label; break; } } if (changeFlag == true) { comboLabel.text = combo.selectedItem.label; } combo.visible = false; comboLabel.visible = true; } else if ( selection == "selected" ) { selectedItem = item; for( var i = 0; i < combo.dataProvider.length; i++ ) { if( combo.dataProvider[i].data == item[ getDataLabel() ] ) { combo.selectedIndex = i; break; } } comboLabel.visible = false; combo.visible = true; combo.setFocus( false ); } } function getPreferredHeight( Void ) : Number { return 20; } function getPreferredWidth( Void ) : Number { return 125; } function reorder( datos : Array, choice : String ) : Array { var index:Number = 0 var newArray = new Array() for( var i=0; i < datos.length; i++ ) { if( datos[i].label != choice ) { index++; newArray[index] = datos[i]; } else { newArray[0] = datos[i]; } } return newArray; } function change() { selectedItem[ getDataLabel() ] = combo.selectedItem; changeFlag = true; } function enter() { if ( combo.text != undefined && combo.text.length > 0 ) { dataProvider.addItem( combo.text ); selectedItem[ getDataLabel() ] = combo.text; } } function draw() : Void { super.draw(); if ( combo.text_mc.border_mc.getDepth() > combo.text_mc.label.getDepth() ) combo.text_mc.border_mc.swapDepths( combo.text_mc.label ); } } --- In [email protected], "Rajesh Jayabalan" <[EMAIL PROTECTED]> wrote: > Hi, > > I found that i had to set > comboLabel.text = combo.dataProvider[i].label; > for it to display the correct values. > > Regards > Rajesh J > > > --- In [email protected], "Rajesh Jayabalan" <[EMAIL PROTECTED]> wrote: > > Hi Sree, > > > > That helped an another solution that I found was to use > > > > combo.dataProvider = parentDocument.clTypeSrv.result.types.type; > > > > in my setValue method of the cell renderer. > > > > Now my combobox is showing up fine, but it is not selecting any thing > > by default and when I select some option and move to a diffent row I > > see [object,object] in there. I think this is because the example I am > > using does not have a data and a label while mine has > > > > the xml I am using is > > > > <?xml version="1.0" encoding="utf-8" ?> > > <types> > > <type label="-- Select --" data="" /> > > <type label="Advertising Company" data="AD/PROMO CO" /> > > <type label="Broker" data="BROKER" /> > > <type label="Clearing Company" data="CLEARING" /> > > <type label="Agency" data="DEMO AGENCY" /> > > <type label="Distributor" data="DISTRIBUTORS" /> > > <type label="Manufacturer" data="MANUFACTURER" /> > > <type label="Marketing Company" data="MARKETING CO" /> > > <type label="Other" data="OTHER" /> > > <type label="Retailer" data="RETAILER" /> > > </types> > > > > > > my setValue looks like > > > > function setValue( str : String, item : Object, selection : String ) : > > Void > > { > > //combo.dataProvider = parentDocument.clTypeSrv.result.types.type; > > if ( item == undefined ) > > { > > comboLabel.visible = false; > > combo.visible = false; > > return; > > } > > > > if ( selection == "normal" || selection == "highlighted" ) > > { > > comboLabel.text = item[ getDataLabel() ]; > > combo.visible = false; > > comboLabel.visible = true; > > } > > else if ( selection == "selected" ) > > { > > selectedItem = item; > > > > for( var i = 0; i < combo.dataProvider.length; i++ ) > > { > > if( combo.dataProvider[i] == item[ getDataLabel() ] ) > > { > > combo.selectedIndex = i; > > break; > > } > > } > > comboLabel.visible = false; > > combo.visible = true; > > combo.setFocus( false ); > > } > > } > > > > I thought maybe there might be a method getData in the list that I can > > use but I don't think there is one. > > > > I am not sure how to more forward > > > > Rajesh J Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

