ok..so I am creating combobox grid cell renderers with Flash .as code for a ColdFusion routine that has 4 pages..I need two of these comboboxes - one each in two different cfgrids on seperate pages...I can create the cell renderer for one or the other of the comboboxes consistently..but need both to be available..
I finally figured out that the cell renderer code has to have the contsructor named the same as the class..and then it works - but only sometimes!! I do not know what makes it decide to display both comboboxes one time and not to display most of the time..
I have tried putting in a delay..but that did not work, so I took it back out...
I am at my witt's end! What is going wrong with the renderers?
here's the code for first of the renderers:
import mx.core.UIComponent import mx.controls.ComboBox class ComboBoxCellNew extends UIComponent { var combo : MovieClip; var owner : MovieClip; // The row that contains the cell. var listOwner : MovieClip; // 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 //constructor function: must be same name as the class function ComboBoxCellNew() { } function createChildren(Void) : Void { //Creates a ComboBox object and listens for changes combo = createObject("ComboBox", "Combo", 0, {styleName:this, owner:this}); combo.addEventListener("change", this); combo.labelField = "cellselectdesc"; combo.dataProvider = _global.COMBOBOX_DATA_PROVIDER; size(); } // note that setSize is implemented by UIComponent and calls size(), after setting // __width and __height function size(Void) : Void { var h = __height; var w = __width; combo.setSize(w - 2, Math.max(h, listOwner.rowHeight - 2)); } public function setValue(str:String, item:Object, sel:Boolean) : Void { /* Sets the ComboBox to the correspoinding cell data from the list owner's data provider if the cell data matches with any items available for the ComboBox. */ var drawCombo:Boolean = true; if (item[getDataLabel()]!=undefined) { /* For each item's data in the ComboBox, verify if it matches the assigned data for the cell this ComboBox is in. Set the selectedIndex of the ComboBox to what matches. */ for(var i:Number = 0; iand the second one:
import mx.core.UIComponent import mx.controls.ComboBox class ComboBoxCellNew2 extends UIComponent { var combo : MovieClip; var owner : MovieClip; // The row that contains the cell. var listOwner : MovieClip; // 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 //constructor function: must be same name as the class function ComboBoxCellNew2() { } function createChildren(Void) : Void { //Creates a ComboBox object and listens for changes combo = createObject("ComboBox", "Combo", 0, {styleName:this, owner:this}); combo.addEventListener("change", this); combo.labelField = "cellselectdesc"; combo.dataProvider = _global.COMBOBOX_DATA_PROVIDER2; size(); } // note that setSize is implemented by UIComponent and calls size(), after setting // __width and __height function size(Void) : Void { var h = __height; var w = __width; combo.setSize(w - 2, Math.max(h, listOwner.rowHeight - 2)); } public function setValue(str:String, item:Object, sel:Boolean) : Void { /* Sets the ComboBox to the correspoinding cell data from the list owner's data provider if the cell data matches with any items available for the ComboBox. */ var drawCombo:Boolean = true; if (item[getDataLabel()]!=undefined) { /* For each item's data in the ComboBox, verify if it matches the assigned data for the cell this ComboBox is in. Set the selectedIndex of the ComboBox to what matches. */ for(var i:Number = 0; ihere is the code that calls these routines in the ColdFusion code that loads the dataproviders (I can tell that they are getting loaded correctly):
private function loader():Void { _root.getSelectData(); _root.getSelectDataRestricted(); } function getSelectData(){ //create connection var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway/"); //declare service var myService:mx.remoting.NetServiceProxy; var responseHandler = {}; var COMBOBOX_DATA_PROVIDER = COMBOBOX_DATA_PROVIDER; responseHandler.onResult = function( results: Object ):Void { //when results are back, populate the COMBOBOX_DATA_PROVIDER //then set the cellRenderer _global.COMBOBOX_DATA_PROVIDER = results; _root.usersLinksGrid.getColumnAt(4).cellRenderer = ComboBoxCellNew; alert(results.length.toString()+ " OnResult GetSelectData ComboBox "); } responseHandler.onStatus = function( stat: Object ):Void { //if there is any error, show an alert alert("Error while calling cfc:" + stat.description); } myService = connection.getService("fobs.components.wfas", responseHandler ); myService.getReviewTypes(); } function getSelectDataRestricted(){ //create connection var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway/"); //declare service var myService:mx.remoting.NetServiceProxy; var responseHandler = {}; var COMBOBOX_DATA_PROVIDER2 = COMBOBOX_DATA_PROVIDER2; responseHandler.onResult = function( results: Object ):Void { //when results are back, populate the COMBOBOX_DATA_PROVIDER //then set the cellRenderer _global.COMBOBOX_DATA_PROVIDER2 = results; _root.ackGrid.getColumnAt(2).cellRenderer = ComboBoxCellNew2; alert(results.length.toString() + " OnResult GetSelectDataRestricted ComboBox "); } responseHandler.onStatus = function( stat: Object ):Void { //if there is any error, show an alert alert("Error while calling cfc:" + stat.description); } myService = connection.getService("fobs.components.wfas", responseHandler ); myService.getReviewTypes("I"); //alert('right here'); }and here is the code that is called in wfas.cfc that provides the dynamic data:
<cffunction name="getReviewTypes" access="remote" returntype="query"> <cfargument name="restricted" type="string" required="no" default=""> <cftry> <cfquery name="reviewTypes" datasource="#application.gsg9_dsn#"> SELECT REVIEW_ID, REVIEW_DESC, REVIEW_ID "cellselectopt", REVIEW_DESC "cellselectdesc" FROM WFAS.WFAS_TABLE_REVIEW_TYPE <cfif len(trim(restricted))> WHERE REVIEW_OPT_TYPE <> 'I' </cfif> ORDER BY SEQ_ORDER </cfquery> <cfcatch> <cfset request.errorObj.record(getbasetemplatepath(),getcurrentTemplatePath(),cgi.sessionid,cfcatch,'',"WFAS")> </cfcatch> </cftry> <cfreturn reviewTypes>
ETA: I can make both cell renderers show up by making the data non-dynamic..(but that defeats the purpose of having the data in a database!!) like this:
private static var COMBOBOX_DATA_PROVIDER : Array = [ {data:'I',label:'FYI'},{data:'M',label:'Mngmt'},{data:'R',label:'Review'}];