Ok, I have minimized this issue to the bare bones, and not only reproduce the 
problem but made it worse.  Now the enabled state is not even correct on 
initialize.  But the trace() shows that the ComboBox.enabled property has been 
correctly set.  So I hope I am missing something easy.  Note that I hve 
stripped out all of the functionality from the ComboBox renderer except for the 
enable/disable.  Below are the renderer and a test app.

TIA.
Tracy

CBODisableIR.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml"; initialize="init()" >
<mx:Script><![CDATA[
  import mx.controls.DataGrid;
  import mx.collections.ArrayCollection;
  private var _oItem:Object;  
  
  private function init():void  {
    this.dataProvider = new ArrayCollection(["AAAA","bbbb","cccc","dddd"]);
  }//init
  
  override public function set data(value:Object):void  {
    super.data = value;
    _oItem = value;
    invalidateProperties();
  }//set data
  
  override protected function commitProperties():void {
    super.commitProperties(); 
    if (_oItem) {
      var bDisabled:Boolean = !_oItem.disabledFlag
      this.enabled = bDisabled;
      trace("commitProperties - value:" + _oItem.value 
            + ", DISABLED=" + (this.enabled == false));
    }                 
  }//commitProperties
    
]]></mx:Script>
</mx:ComboBox>

CBODisableTest.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml";
    layout="vertical" horizontalAlign="left"
    creationComplete="init()">
<mx:Script><![CDATA[
  import mx.collections.XMLListCollection;
  import mx.collections.ArrayCollection;
  import CBODisableIR;
  
  [Bindable]private var _acMainDP1:ArrayCollection = new ArrayCollection(); 
  
  private function init():void {
    buildMainDp();
  }
  
  private function buildMainDp():void 
  {
    _acMainDP1.addItem({value:"C", disabledFlag: false});
    _acMainDP1.addItem({value:"2", disabledFlag: true});
    _acMainDP1.addItem({value:"BLUE", disabledFlag: false});
  }//buildMainDp

]]></mx:Script>
  <mx:DataGrid id="dg1" width="300" 
      editable="true"
                dataProvider="{_acMainDP1}"  >
    <mx:columns>
      <mx:DataGridColumn headerText="Value" 
          width="60"
          dataField="value" 
          editable="false" />
      <mx:DataGridColumn headerText="Disable Combo" 
          width="60" headerWordWrap="true"
          dataField="disabledFlag" 
          itemRenderer="mx.controls.CheckBox"  
          rendererIsEditor="true" 
          editorDataField="selected"/>
        <mx:DataGridColumn headerText="CBO Value"
            dataField="value"  
                  itemRenderer="CBODisableIR" 
                  editable="false"  />
    </mx:columns>
  </mx:DataGrid>
  <mx:Button label="invalidateList()" click="{dg1.invalidateList()}" />
</mx:Application>




________________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 
Tracy Spratt
Sent: Thursday, November 29, 2007 12:10 PM
To: [email protected]
Subject: RE: [flexcomponents] How to call invalidateList() from within a 
renderer

You are right, I was so close I jumped to a conclusion.  The ComboBox should 
enable properly without another redraw.  I will try to find out why.

The renderer subclasses an extended ComboBox with selectedValue functionality, 
perhaps that is causing a problem.  I'll try this with the stock CBO to narrow 
the variables.

Any other suggestins will be welcome.

Tracy

________________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 
Alex Harui
Sent: Thursday, November 29, 2007 12:43 AM
To: [email protected]
Subject: RE: [flexcomponents] How to call invalidateList() from within a 
renderer

Usually, you renderers get called from within updateDisplayList and 
invalidateList does not work from within UDL otherwise it could repeat that 
cycle forever.  There's always callLater, but I'd first wonder why the Combo 
doesn't enable properly and needs the redraw.

________________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 
Tracy Spratt
Sent: Wednesday, November 28, 2007 9:21 PM
To: [email protected]
Subject: [flexcomponents] How to call invalidateList() from within a renderer
I want my ComboBox itemRenderer to be disabled based on a "disabledFlag" 
property in the dataProviderItem.
I have a CheckBox renderer in another column that updates that property.
The ComboBox renderers display fine on initialize, with the correct rows 
disabled
But when I click the checkbox, even though the code in the CBO renderer's set 
data() and commitProperties runs correctly and sets the Combobox enabled 
property correctly, the ComboBox interactivity is not correct until something 
redraws the list, like scrolling.
I can make it work with an external button that calls invalidateList() on the 
DataGrid, but I want to do that from within the renderer.  I have tried:
  /**  called from commitProperties */
  private function setEnabled():void
  {
    this.enabled = !_oItem.disabledFlag;
    DataGrid(_dgListData.owner).invalidateList();
  }//setEnabled
But this does not seem to do anything.
Where, when and how should I make the invalidateList call from within my 
renderer?

 

Reply via email to