OK, just because you already stated that you looked at the source code, I hope posting the code here is not going to be such a big offence - I recall few people exchanging messages on how you can do it with debugger, etc.
I am going to post a little bit more generic code - allowing you to show DATAGRID as a dropdown. Also, please note that this code is targeted toward wider audience allowing you to define cellrenderers along with other column attributes via mxml as well. Finally, this is going to show you the end of very long rope - please use caution not to explore it to much as it is going to become a problem during migration to Flex 2. Step 1. Create custom ComboBox and define __columns property on it ///////////////////////////////////// import mx.controls.ComboBox; import mx.controls.DataGrid; import mx.controls.gridclasses.DataGridColumn; import mx.core.UIObject; import mx.effects.Tween; import mx.managers.PopUpManager; import mx.styles.CSSStyleSheet; class common.DGComboBox extends ComboBox { var __columns:Array; var showHeaders :Boolean = false; [Inspectable(arrayType="DataGridColumn", category="Other", verbose=1)] [ChangeEvent("columnsChanged")] function get columns() : Array { return __columns; } function set columns(a:Array) { __columns = a; setDropdownColumns(); dispatchEvent({type:"columnsChanged"}); } function setDropdownColumns() { if (__dropdown == undefined && __columns != undefined) return; __dropdown.columns = __columns; } //-- Creation (dropdown) ----------------------------------- function getDropdown() : Object { if (!initialized) return undefined; if (!hasDropdown()) { var o = new Object(); o.styleName = this; var nonInheritingStyleSheet:CSSStyleSheet = new CSSStyleSheet(); // preilly: the following line is a workaround for what seems like a AS // compiler bug. var dropdownBorderStyle = this.dropdownBorderStyle; if (dropdownBorderStyle != undefined) { o.borderStyle = dropdownBorderStyle; nonInheritingStyleSheet.factory = function() { return { borderStyle: dropdownBorderStyle, selectionDuration: 0, cornerRadius: 5 }; }; } else { nonInheritingStyleSheet.factory = function() { return { selectionDuration: 0, cornerRadius: 5 }; }; } o.nonInheritingStyleSheet = nonInheritingStyleSheet; o.visible = false; // Don't display a tween when the selection changes. The dropdown // menu is about to appear anyway, and other processing can make // the tween look choppy. o.selectionDuration = 0; // THIS IS OVERRIDE - BEWARE VVVVVVVVVVVVVVVV o.showHeaders = showHeaders; __dropdown = PopUpManager.createPopUp(this, DataGrid, false, o, true); // Have to destroy the List Box's mask since we also // have a mask and masks inside masks don't work on Win XP. Player Bug. // Make sure this is done before calling super.createChildren(). __dropdown.scroller.mask.removeMovieClip(); // Set up a data provider in case one doesn't yet exist, so we can share it with the dropdown listbox. if (dataProvider == undefined) dataProvider = new Array(); __dropdown.setDataProvider(dataProvider); __dropdown.selectMultiple = false; __dropdown.rowCount = rowCount; __dropdown.width = __dropdownWidth; __dropdown.selectedIndex = selectedIndex; __dropdown.vScrollPolicy = "auto"; __dropdown.labelField = __labelField; __dropdown.labelFunction = __labelFunction; __dropdown.owner = this; __dropdown.changeHandler = _changeHandler; __dropdown.addEventHandler("change"); __dropdown.scrollHandler = _scrollHandler; __dropdown.addEventHandler("scroll"); __dropdown.itemRollOverHandler = _itemRollOverHandler; __dropdown.addEventHandler("itemRollOver"); __dropdown.itemRollOutHandler = _itemRollOutHandler; __dropdown.addEventHandler("itemRollOut"); __dropdown.resizeHandler = _resizeHandler; __dropdown.addEventHandler("resize"); __dropdown.mouseDownOutsideHandler = function (eventObj) { if (this._visible == false) return; var o = this.owner; var pt = new Object(); pt.x = o._root._xmouse; pt.y = o._root._ymouse; o._root.localToGlobal(pt); if( o.hitTest(pt.x, pt.y, false) ) { // do nothing } else { o.close(); } } __dropdown.addEventHandler ("mouseDownOutside"); __dropdown.onTweenUpdate = function(v) { _y = v; }; setDropdownColumns(); __dropdown.setSize(__dropdownWidth, __dropdown.preferredHeight); __dropdown.redraw(); __dropdown.bug97664 = {}; __dropdown.bug97664.owner = this; __dropdown.bug97664.onResize = function() { // hide immediately this.owner.__dropdown._visible = false; this.owner._showingDropdown = false; } Stage.addListener(__dropdown.bug97664); // Create the mask that keeps the dropdown listbox only visible below the textfield. createObjectWithStyles ("BoundingBox", "mask",20); mask._y = border_mc.height; mask._width = __dropdownWidth; mask._height = __dropdown.preferredHeight; mask._visible = false; __dropdown.setMask(mask); } return __dropdown; } } /////////////////////////////////// Step 2. Use it ;) <common:DGComboBox xmlns:common="common.*" xmlns:mx="http://www.macromedia.com/2003/mxml" dropdownWidth="500" > <common:columns> <mx:Array> <mx:DataGridColumn columnName="name" width="100"/> <mx:DataGridColumn columnName="associated_company_name" width="150"/> <mx:DataGridColumn columnName="email" width="150" /> <mx:DataGridColumn columnName="phone" width="100"/> </mx:Array> </common:columns> </common:DGComboBox> Enjoy, Anatole Tartakovsky [EMAIL PROTECTED] --- In flexcoders@yahoogroups.com, "moyosaned" <[EMAIL PROTECTED]> wrote: > > Ok just looked in to the source of a combobox... > > __dropdown = PopUpManager.createPopUp(this, List, false, o, true); > > This is probably why the cellRenderer is not working.. > Somebody got an solution..ELse I got to build my own combobox. which I > find overdone. > > > --- In flexcoders@yahoogroups.com, "moyosaned" <[EMAIL PROTECTED]> wrote: > > > > created an cellRenderer, I want to use this cellrenderer in a combobox; > > > > I tried the following: > > > > <?xml version="1.0" encoding="utf-8"?> > > <mx:ComboBox xmlns:mx="http://www.macromedia.com/2003/mxml" > > creationComplete="initApp()"> > > > > <mx:Script> > > <![CDATA[ > > import bla.bla.FlexBoxRenderer; > > import bla.bla.MultiLineCell; > > import org.panda.gpn.utils.Debug; > > > > public function initApp():Void{ > > > > this.dropdown.setCellRenderer(MultiLineCell); > > > > } > > > > ]]> > > </mx:Script> > > > > </mx:ComboBox> > > > > I use the creationComplete, otherwise the dropdown does not exists > > where I have to set the cellRenderer for. but nothing happens after > > it, I am not tracing anything when I fill the Combobox.dataprovider > > > > So anybody > > > ------------------------ Yahoo! Groups Sponsor --------------------~--> Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life. http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/nhFolB/TM --------------------------------------------------------------------~-> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 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/