2012-01-20 8 views
0

사용자 정의 ItemRenderer (IR)이있는 TileList가 있습니다. IR은 TextInput, TextArea 또는 ComboBox가 될 수 있습니다. 한 행에 TextArea가 있으면이 행에 다른 행보다 높이가 있어야합니다. 나는 모든 행이 결국 같은 높이를 가져야하는지 상관하지 않습니다. 내가 신경 쓰는 것은 TextArea가없는 폼이 있다면 행의 높이를 가능한 한 낮게하고 싶습니다.TileList에있는 행의 가변 가변 높이

일부 작업을 수행 한 후 다음 코드를 얻었습니다. 그러나, 당신이 동봉 한 스크린 샷에서 감사 할 것이므로, 나는 내가 원하는 것을 얻지 못했습니다. 처음 양식에 입력하면 잘못 보입니다. 그러나 두 번째로 입력하면 괜찮아 보입니다. 그러나 다른 필드가있는 다른 양식을 입력하고 직전에 열어 본 양식을 다시 열면 다시 잘못 보입니다. 그것이 틀리게 보일 때, 각 행에는 standart 고도가 보인다.

내가 무엇이 누락 되었습니까? 어떤 방법으로 TileList를 사용자 화해야합니까? invalidateDisplayList 및 invalidateSize를 잘못된 위치에 배치 했습니까?

형태 1 케이스 잘못된 :
http://flic.kr/p/bfJSUM

형태 1 케이스 OK :
http://flic.kr/p/bfJSQT

형태 2 케이스 잘못된 :
http://flic.kr/p/bfJSSn

,174,

양식이 사례 확인 :
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"이라는 세 가지 속성을 모두 추가했습니다. 또한 필요없는 invalidateDisplayList 및 invalidateSize에 대한 호출을 삭제했습니다. 고마워요 !!! – Roger

+0

나는 너무 일찍 말했습니다. 내가 방금 해결 한 것은 처음 양식에 들어가면 모든 것이 괜찮습니다. 그러나 다른 필드가있는 다른 양식으로 이동하여 이전 양식을 다시 열면 서식이 다시 잘못됩니다. – Roger