1 Reply Latest reply on Oct 1, 2008 8:36 AM by Newsgroup_User

    Strange problem in using TextBox in AdvancedDataGrid

    COKFlex Level 1
      Hi All,

      I am using AdvancedDataGrid to dispay series of rows which has 4 columns and I am using TextBox for all the columns using itemRenderer.

      Earlier I used a Label and I had the height property hardcoded for each column to display multiline text, then I realized that If I use the Text component it will get adjusted to the multiline text automatically.

      Now, the problem I am facing is that, I am using

      Code:

      myGrid.measureHeightOfItems(0, singlePageDp.length);

      to calculate the height of the grid, since I set variableRowHeight="true" for the ADG, and I also have to display multiline, so the height may vary.

      When I was using the Label in the ADG to display values in the itemRenderer it was giving the correct rowHeight(Also I hardcoded the height for the labels). But after I replace the Label to Text, I am always getting the rowHeight as 22 ( which I found wrong).

      The code below I was using earlier with the Label,

      Code:

      <mx:AdvancedDataGridColumn backgroundColor="black" headerText="Name">
      <mx:itemRenderer>
      <mx:Component>
      <mx:Label text="{data.getNames()}" height="{data.names.length * bodyFontsize}"/>
      </mx:Component>
      </mx:itemRenderer>
      </mx:AdvancedDataGridColumn>

      to avoid the hardcoded height I replace the Label with the text like below
      where I am getting the same output.

      Code:

      <mx:AdvancedDataGridColumn backgroundColor="black" headerText="Name">
      <mx:itemRenderer>
      <mx:Component>
      <mx:Text text="{data.getNames()}"/>
      </mx:Component>
      </mx:itemRenderer>
      </mx:AdvancedDataGridColumn>

      How I can calculate the rowHeight in this case?

      Any suggestions would be helpful.

      Thanks.
        • 1. Re: Strange problem in using TextBox in AdvancedDataGrid
          Level 7

          "COKFlex" <webforumsuser@macromedia.com> wrote in message
          news:gbuu7n$5uo$1@forums.macromedia.com...
          > Hi All,
          >
          > I am using AdvancedDataGrid to dispay series of rows which has 4 columns
          > and I
          > am using TextBox for all the columns using itemRenderer.
          >
          > Earlier I used a Label and I had the height property hardcoded for each
          > column
          > to display multiline text, then I realized that If I use the Text
          > component it
          > will get adjusted to the multiline text automatically.
          >
          > Now, the problem I am facing is that, I am using
          >
          > Code:
          >
          > myGrid.measureHeightOfItems(0, singlePageDp.length);

          I think you need to override the measure() function of your component to get
          an accurate measure of your text. I don't think this is as straightforward
          as it ought to be, so I'd suggest a search of the yahoo flexcoders archive.
          I _think_ the term you may want to look for is viewMetrics, but I could be
          wrong about that.

          HTH;

          Amy