0 Replies Latest reply on Jun 28, 2010 2:55 PM by suriandflex

    Increase CollapsiblePanel width size

    suriandflex

      I have the following code, problem is i am unable increase the width of the collapsible panel that is being rendered.

      I just need to expand the panel itself but not the "Column Label"

       

      Any help would be really appreciated

      Thanks!!

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                      xmlns:hassegContainers="org.hasseg.containers.*">
         
          <mx:Script>
              <![CDATA[
                  import mx.collections.ArrayCollection;
                  import mx.controls.Alert;
                 
                  [Bindable]
                  protected function canvas_clickHandler(event:MouseEvent):void
                  {
                      cnvs.setChildIndex(event.currentTarget as DisplayObject,cnvs.numChildren-1);
                     
                  }

       

                  var dpFlat:ArrayCollection = new ArrayCollection([
                      {Months:"Jan 2009 - Feb 2009",children: [
                                   {Months:"Jan 2009", Amount:"$100",Paid:"YES",Waived:"NO", Waiver_Reason:"", Override_Reason:""},
                                   {Months:"Feb 2009", Amount:"$100",Paid:"YES",Waived:"NO", Waiver_Reason:"", Override_Reason:""}]},
                      {Months:"Mar 2009 - Apr 2009",children: [
                              {Months:"Mar 2009", Amount:"$100",Paid:"NO",Waived:"YES", Waiver_Reason:"Presidential Emergency", Override_Reason:""}, 
                              {Months:"Apr 2009", Amount:"$100",Paid:"NO",Waived:"YES", Waiver_Reason:"Presidential Emergency", Override_Reason:""}]},
                  ]);
              ]]>
          </mx:Script>
         
          <mx:Style>
              .myCPStyle {
                  borderThicknessLeft: 0;
                  borderThicknessTop: 0;
                  borderThicknessBottom: 0;
                  borderThicknessRight: 0;
                  headerHeight: 20;
                  dropShadowEnabled: false;
                  headerColors: #d9d9d9, #ffffff;
                  borderAlpha: 1;
                  backgroundAlpha: 1;
                  paddingTop: 4;
                  paddingLeft: 4;
                  paddingRight: 4;
                  verticalGap: 4;
                  width:200           
              }
          </mx:Style>

       

              <mx:Canvas height="300" width="732" id="cnvs">

       

                  <mx:Box width="300" click="canvas_clickHandler(event)">
                      <hassegContainers:CollapsiblePanel
                          title="Column Labels"
                          width="100"
                          open="false"
                          styleName="myCPStyle"
                          >
                          <mx:Label text="Filter"/>
                          <mx:CheckBox label="Select All"/>
                          <mx:CheckBox label="Override Reason"/>
                          <mx:CheckBox label="Pending Reason"/>
                          <mx:Button label="OK"/>
                          <mx:Button label="Cancel"/>
                      </hassegContainers:CollapsiblePanel>
                  </mx:Box>
                          <mx:AdvancedDataGrid id="myADG" width="100%" height="246" x="1" y="25">   
                                  <mx:dataProvider>
                                      <mx:HierarchicalData source="{dpFlat}"/>
                                  </mx:dataProvider>
                                  <mx:columns>
                                      <mx:AdvancedDataGridColumn dataField="Months" fontWeight="bold"/>
                                      <mx:AdvancedDataGridColumn dataField="Amount"/>
                                      <mx:AdvancedDataGridColumn dataField="Paid"/>
                                      <mx:AdvancedDataGridColumn dataField="Waived"/>
                                      <mx:AdvancedDataGridColumn dataField="Waiver_Reason" headerText="Waiver Reason"/>
                                      <mx:AdvancedDataGridColumn dataField="Override_Reason" headerText="Override Reason"/>
                                  </mx:columns>
                              </mx:AdvancedDataGrid>
                     

       

              </mx:Canvas>
      </mx:Application>

       

      ****************************************************************************************** *********************

      ****************************************************************************************** *********************

      ****************************************************************************************** *********************

      ****************************************************************************************** *********************

       

      // ActionScript file
      /*

       

      The MIT License

       

      Copyright (c) 2007-2008 Ali Rantakari of hasseg.org

       

      Permission is hereby granted, free of charge, to any person obtaining a copy
      of this software and associated documentation files (the "Software"), to deal
      in the Software without restriction, including without limitation the rights
      to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      copies of the Software, and to permit persons to whom the Software is
      furnished to do so, subject to the following conditions:

       

      The above copyright notice and this permission notice shall be included in
      all copies or substantial portions of the Software.

       

      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      THE SOFTWARE.

       

      */

       

      package org.hasseg.containers {
         
          import flash.events.*;
          import mx.effects.AnimateProperty;
          import mx.events.*;
          import mx.containers.Panel;
          import mx.core.ScrollPolicy;
         
         
          /**
           * The icon designating a "closed" state
           */
          [Style(name="closedIcon", property="closedIcon", type="Object")]
         
          /**
           * The icon designating an "open" state
           */
          [Style(name="openIcon", property="openIcon", type="Object")]
         
          /**
           * This is a Panel that can be collapsed and expanded by clicking on the header.
           *
           * @author Ali Rantakari
           */
          public class CollapsiblePanel extends Panel {
             
              private var _creationComplete:Boolean = false;
              private var _open:Boolean = true;
              private var _openAnim:AnimateProperty;
             
             
             
              /**
               * Constructor
               *
               */
              public function CollapsiblePanel(aOpen:Boolean = true):void
              {
                  super();
                  open = aOpen;
                  this.addEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler);
              }
             
             
             
             
             
             
             
             
              // BEGIN: event handlers                ------------------------------------------------------------
             
              private function creationCompleteHandler(event:FlexEvent):void
              {
                  this.horizontalScrollPolicy = ScrollPolicy.OFF;
                  this.verticalScrollPolicy = ScrollPolicy.OFF;
                 
                  _openAnim = new AnimateProperty(this);
                  _openAnim.duration = 300;
                  _openAnim.property = "height";
                 
                  titleBar.addEventListener(MouseEvent.CLICK, headerClickHandler);
                 
                  _creationComplete = true;
              }
             
              private function headerClickHandler(event:MouseEvent):void { toggleOpen(); }
             
              private function callUpdateOpenOnCreationComplete(event:FlexEvent):void { updateOpen(); }
             
              // --end--: event handlers          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
             
             
             
             
             
             
             
             
              // BEGIN: private methods               ------------------------------------------------------------
             
              // sets the height of the component without animation, based
              // on the _open variable
              private function updateOpen():void
              {
                  if (!_open) height = closedHeight;
                  else height = openHeight;
                  setTitleIcon();
              }
             
              // the height that the component should be when open
              private function get openHeight():Number {
                  return measuredHeight;
              }
             
              // the height that the component should be when closed
              private function get closedHeight():Number {
                  var hh:Number = getStyle("headerHeight");
                  if (hh <= 0 || isNaN(hh)) hh = titleBar.height;
                  return hh;
              }
             
              // sets the correct title icon
              private function setTitleIcon():void
              {
                  if (!_open) this.titleIcon = getStyle("closedIcon");
                  else this.titleIcon = getStyle("openIcon");
              }
             
              // --end--: private methods         - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
             
             
             
             
             
             
             
             
              // BEGIN: public methods                ------------------------------------------------------------
             
             
             
              /**
               * Collapses / expands this block (with animation)
               */
              public function toggleOpen():void
              {
                  if (_creationComplete && !_openAnim.isPlaying) {
                     
                      _openAnim.fromValue = _openAnim.target.height;
                      if (!_open) {
                          _openAnim.toValue = openHeight;
                          _open = true;
                          dispatchEvent(new Event(Event.OPEN));
                      }else{
                          _openAnim.toValue = _openAnim.target.closedHeight;
                          _open = false;
                          dispatchEvent(new Event(Event.CLOSE));
                      }
                      setTitleIcon();
                      _openAnim.play();
                     
                  }
                 
              }
             
             
              /**
               * Whether the block is in a expanded (open) state or not
               */
              public function get open():Boolean {
                  return _open;
              }
              /**
               * @private
               */
              public function set open(aValue:Boolean):void {
                  _open = aValue;
                  if (_creationComplete) updateOpen();
                  else this.addEventListener(FlexEvent.CREATION_COMPLETE, callUpdateOpenOnCreationComplete, false, 0, true);
              }
             
             
              /**
               * @private
               */
              override public function invalidateSize():void {
                  super.invalidateSize();
                  if (_creationComplete)
                      if (_open && !_openAnim.isPlaying) this.height = openHeight;
              }
             
             
              // --end--: public methods          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
             
             
          }
         
      }