2012-01-20 16 views
0

私はカスタムItemRenderer(IR)を持つTileListを持っています。 IRはTextInput、TextAreaまたはComboBoxです。行内にTextAreaがある場合は、この行の高さを他の行より高くします。私はすべての行が同じ高さを持っていなければならないかどうか気にしない。私が気にするのは、TextAreaがないフォームがあれば、行の高さを可能な限り低くしたいと思う。TileListの行のフレックス可変幅

いくつかの作業の後、私は次のコードを達成しました。しかし、囲まれたスクリーンショットで感謝するように、私は自分が望むものを達成していません。フォームに初めて入力したときは間違っていますが、2回目に入力すると大丈夫です。しかし、フィールドが異なる別のフォームに入力し、直前に開いたフォームを再び開くと、再び間違って表示されます。見た目が間違っていると、すべての列が高さを持つようです。

何が欠けていますか?何らかの方法でTileListをカスタマイズする必要がありますか? invalidateDisplayListとinvalidateSizeを間違った場所に置いていますか?

形態1ケース誤:
http://flic.kr/p/bfJSUM

形態1ケースOK:
http://flic.kr/p/bfJSQT

形態2ケース誤:

http://flic.kr/p/bfJSSn

様式2ケースOK:
http://flic.kr/p/bfJUwe

TileListコントロール:

<mx:VBox id="camposextras" visible="true" verticalGap="0" horizontalGap="0" width="100%" height="100%" > 
      <mx:TileList wordWrap="true" variableRowHeight="true" width="100%" textAlign="left" columnCount="2" dataProvider="{model.specialfield_issue_list}" itemRenderer="org.nevis.cairngorm.mod.view.IRCampoEspecial" direction="horizontal"> 
      </mx:TileList> 
     </mx:VBox> 

たItemRenderer:

<?xml version="1.0"?> 
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" 
     horizontalAlign="left" verticalAlign="middle" 
     verticalGap="0" borderStyle="none" width="100%" 
    horizontalScrollPolicy="off" verticalScrollPolicy="off" 
    > 

     <mx:Script> 
      <![CDATA[ 
      import mx.controls.TextArea; 
      import mx.controls.Text; 
      import org.nevis.cairngorm.mod.model.ModelLocator; 
      import mx.core.UIComponent; 
      import mx.controls.Label; 
      import mx.controls.ComboBox; 
      import mx.controls.TextInput; 
      import utils.Utils; 
      import mx.collections.ArrayCollection; 
      import mx.controls.Alert; 

      [Bindable] 
      public var model:ModelLocator=ModelLocator.getInstance(); 

      [Bindable] 
      private var fieldLabelVisible:Boolean = false; 

      [Bindable] 
      private var textInputVisible:Boolean = false; 

      [Bindable] 
      private var textAreaVisible:Boolean = false; 

      [Bindable] 
      private var comboBoxVisible:Boolean = false; 

      [Bindable] 
      private var mandatoryLabelVisible:Boolean = false; 

      [Bindable] 
      private var _contenedorHeight:int = 25; 


      public function updata_valor_text(valor:Event):void { 
       data.value=valor.currentTarget.text; 
      } 

      public function updata_valor_combo(valor:Event):void { 
       data.value=valor.currentTarget.selectedItem.valuesspecialfieldid 
      } 

      /** 
      * Make sure IR has real variable height for rows 
      */ 
      override public function get height():Number { 
       //Make sure variableRowHeight is set to true in the container of this IR 
       return _contenedorHeight; 
      } 

      override public function set height(value:Number):void { 
       _contenedorHeight = value; 
      } 

      override public function set data(value:Object):void { 
       var i:int; 
       var sel:int; 

       super.data = value; 

       callLater(function onceAllCreated():void{ 

        if (value){ 

        _contenedorHeight = 25; //Default value 

        fieldLabelVisible = true; 
        lb.text=value.spe_name; 
        lb.toolTip=value.spe_description; 
        lb.width=150; 
        lb.name='etiqueta'; 
        lb.styleName='texto-iza'; 

        switch (value.type){ 
        case "text": 

         if(value.spe_max<=40) { 

          ti.text=value.value; 
          ti.name='texto'; 
          ti.maxChars=value.spe_max; 

          if(value.spe_max<=20) { 
           ti.width=150; 
          } else { 
           ti.width=300; 
          } 

          textInputVisible = true; 
         } else { 
          ta.text=value.value; 
          ta.name='texto'; 
          ta.maxChars=value.spe_max; 

          ta.width=300; 

          textAreaVisible = true; 

          _contenedorHeight = 60; 
         }  
        break; 
        case "select": 
         cb.labelField='val_value'; 
         cb.name='seleccionable'; 

         cb.width=150; 


         comboBoxVisible = true;       
        break; 
        default:break; 
        }  

        if (value.spe_mandatory==1){ 
         mandatory.text="*"; 
         mandatory.toolTip="Mandatory"; 
         mandatory.width=10; 
         mandatory.name='mandatory'; 
         mandatory.styleName='texto-iza';  
         mandatoryLabelVisible = true;  
        } 
        } else { 
         fieldLabelVisible = false; 
         textInputVisible = false; 
         textAreaVisible = false; 
         comboBoxVisible = false; 
         mandatoryLabelVisible = false; 
        } 
        invalidateDisplayList(); 
        invalidateSize(); 
       }); 
      } 

      ]]> 
     </mx:Script> 
    <mx:HBox id="contenedor" toolTip="{data.spe_description}" verticalAlign="middle" horizontalAlign="left" width="100%" height="{_contenedorHeight}"> 
     <mx:Label id="lb" visible="{fieldLabelVisible}" includeInLayout="{fieldLabelVisible}"/> 
     <mx:TextInput id="ti" visible="{textInputVisible}" includeInLayout="{textInputVisible}" change="updata_valor_text(event)"/> 
     <mx:TextArea id="ta" visible="{textAreaVisible}" includeInLayout="{textAreaVisible}" height="50" change="updata_valor_text(event)"/> 
     <mx:ComboBox id="cb" visible="{comboBoxVisible}" includeInLayout="{comboBoxVisible}" change="updata_valor_combo(event)"/> 
     <mx:Label id="mandatory" visible="{mandatoryLabelVisible}" includeInLayout="{mandatoryLabelVisible}"/> 
    </mx:HBox> 
</mx:VBox> 

注:これは、古いアプリですし、それが行われますw i Flex 2 SDK 2.0.1の修正3.

ありがとうございました!

答えて

1

アイテムレンダラーにminHeightを配置できますか?

+0

私はminHeight = "25"を試しましたが、結果は同じです。 – Roger

+0

さて、私は解決策を見つけました。 ItemRendererでは、minHeight = "25" maxHeight = "60" height = "60"の3つのプロパティをすべて設定しました。また、invalidateDisplayListとinvalidateSizeの呼び出しを削除しました。どうもありがとう!!! – Roger

+0

私はあまりにも早く話しました。私がちょうど解決したのは、フォームに入る最初のことはすべてが大丈夫です。しかし、異なるフィールドを持つ別のフォームに移動して前のフォームを再び開くと、フォームが再び間違って取得されます。 – Roger

関連する問題