0 Replies Latest reply on Nov 17, 2011 7:34 AM by Zolotoj

    Spark datagrid - about Editor size

    Zolotoj Level 3

      I am observing some things related to an item editor.

      It seems to me that the following code gives different results based on an item editor type:

       

      columns.getItemAt(0, 0).grid.getColumnWidth(0);

       

      When an item editor, for example, has a dropdown (code simplified):

      <?xml version="1.0" encoding="utf-8"?>

      <!--

       

      ADOBE SYSTEMS INCORPORATED

      Copyright 2010 Adobe Systems Incorporated

      All Rights Reserved.

       

      NOTICE: Adobe permits you to use, modify, and distribute this file

      in accordance with the terms of the license agreement accompanying it.

       

      -->

      <!--- The ComboBoxGridItemEditor class defines an item renderer for use

      with the Spark grid controls, such as DataGrid and Grid.

      The ComboBoxGridItemEditor  displays a drop-down list of cell values.

      Select a value to set the new value of the cell.

       

      <p>The following example shows a GridColumn using the ComboBoxGridItemEditor

      as its item editor:</p>

       

      @see spark.components.DataGrid

      @see spark.components.Grid

      @see spark.components.gridClasses.GridColumn

       

      @langversion 3.0

      @playerversion Flash 10

      @playerversion AIR 2.5

      @productversion Flex 4.5

       

      -->

      <s:GridItemEditor xmlns:fx="http://ns.adobe.com/mxml/2009"

                        xmlns:s="library://ns.adobe.com/flex/spark"

                        xmlns:mx="library://ns.adobe.com/flex/mx"

                        xmlns:gridEditorClasses="spark.components.gridEditorClasses.*"

                        >

       

          <fx:Script>

              <![CDATA[

                  import mx.binding.utils.BindingUtils;

                  import mx.collections.ArrayCollection;

                  import mx.collections.ArrayList;

                  import mx.collections.IList;

                  import mx.core.IVisualElement;

       

                  import spark.components.DataGrid;

                  import spark.events.DropDownEvent;

       

                  //--------------------------------------------------------------------------

                  //

                  //  Overriden properties

                  //

                  //--------------------------------------------------------------------------

       

                  /**

                   *  @private

                   *

                   *  returns the selected value in the comboBox.

                   */

                  override public function get value():Object

                  {

                      if (comboBox.selectedItem)

                          return comboBox.selectedItem.value;

                      else

                          return null;

                  }

       

                  /**

                   *  @private

                   *

                   *  Set the selected item of the combo box with the data from the

                   *  item.

                   */

                  override public function set value(newValue:Object):void

                  {

                      comboBox.selectedItem = newValue;

                  }

       

                  //--------------------------------------------------------------------------

                  //

                  //  Properties

                  //

                  //--------------------------------------------------------------------------

       

                  //----------------------------------

                  //  dataProvider

                  //----------------------------------

       

                  private var _dataProvider:IList;

       

                  [Bindable("comboBoxGridItemEditorDataProviderChanged")]

       

                  /**

                   *  The data provider for the combox box in the item editor.

                   *

                   *  @langversion 3.0

                   *  @playerversion Flash 10

                   *  @playerversion AIR 2.5

                   *  @productversion Flex 4.5

                   */

                  override public function setFocus():void

                  {

                      // delegate focus to the combox box.

                      comboBox.setFocus();

                  }

       

              ]]>

          </fx:Script>

       

          <!--- @private

       

          Background to cover the cell that the ComboBox control does not.

       

          @langversion 3.0

          @playerversion Flash 10

          @playerversion AIR 2.5

          @productversion Flex 4.5

          -->

       

       

          <!--- The item editor's ComboBox control.

       

          @langversion 3.0

          @playerversion Flash 10

          @playerversion AIR 2.5

          @productversion Flex 4.5

          -->

          <s:DropDownList id="comboBox" width="100%"

                          />

       

      </s:GridItemEditor>

       

      then the code in question will return correct column width,

      but I use a textArea:

      <s:TextArea id="textArea" fontSize="11" fontFamily="Courier New" width="100%" />  

      then the result is wrong - it's smaller then I would expect.

      LIke I said, it seems to me. May be I am iterpreting results wrongly.

      Can someone clarify?

       

      Thanks