2 Replies Latest reply on Feb 6, 2009 6:50 AM by ice9_us

    Datagrad, Rowheight depend on grid's height

    AlanSean
      We are developing a touch screen application using flex.

      We would like the datagrids, which can vary in height on each component (or if the screen is resized) to have a rowheight that is at least aa pixels high, but also that there is maximal use of the space available for the rows, so there isn't a part row at the bottom.

      e.g. at least 50 pixels high, datagrid is 380 pixels. We can get 7 full rows at 50, but that would leave 30pixels for the last row, not big enough to touch, so I make 7 rows at 54 pixels, leaving 2 pixels which I make unselectable, unhighlightable. An odd 2 pixels at the bottom is better than an odd 30.

      First attempt, override the calculateRowHeight and return the height here - perfect, if there is data in the grid, until there is data, the row height is the default. While this isn't a major issue because there is nothing to see or select, the problem is that when it is populated, the rows resize and it looks odd, the same if the grid is resized, the row heights are not redetermined.

      Second attempt, override updateDisplayList then call the super classes' updateDisplayList, and set the row height in here - perfect, if the grid has a fixed height.

      Now I have a problem, if the grid is used in canvases, and height is dynamic based on other control positions, the header height is calculated in the UpdateDisplayList further up the chain of the classes which DataGrid extends from. Without the headerheight, I can't calculate the best row size, because I dont know what space is available.

      (Interestingly for some reason, if there is no data in the grid, the headerHeight inherits the row height initially, this is tagged in the class as to prevent bad behaviour from PDG?? This caused me an interesting problem with the grid continually invalidating its self because I was setting differing rowheights each time because the header height differed)

      Am I missing a much easier way of achieving this? I am thinking of just setting an explicit header height and leave my code as is, but it would be preferable to make it all configurable/dynamic and still work.
        • 1. Re: Datagrad, Rowheight depend on grid's height
          Level 7

          "AlanSean" <webforumsuser@macromedia.com> wrote in message
          news:gmfdit$a1t$1@forums.macromedia.com...
          > We are developing a touch screen application using flex.
          >
          > We would like the datagrids, which can vary in height on each component
          > (or if
          > the screen is resized) to have a rowheight that is at least aa pixels
          > high, but
          > also that there is maximal use of the space available for the rows, so
          > there
          > isn't a part row at the bottom.
          >
          > e.g. at least 50 pixels high, datagrid is 380 pixels. We can get 7 full
          > rows
          > at 50, but that would leave 30pixels for the last row, not big enough to
          > touch,
          > so I make 7 rows at 54 pixels, leaving 2 pixels which I make unselectable,
          > unhighlightable. An odd 2 pixels at the bottom is better than an odd 30.
          >
          > First attempt, override the calculateRowHeight and return the height
          > here -
          > perfect, if there is data in the grid, until there is data, the row height
          > is
          > the default. While this isn't a major issue because there is nothing to
          > see or
          > select, the problem is that when it is populated, the rows resize and it
          > looks
          > odd, the same if the grid is resized, the row heights are not
          > redetermined.
          >
          > Second attempt, override updateDisplayList then call the super classes'
          > updateDisplayList, and set the row height in here - perfect, if the grid
          > has a
          > fixed height.
          >
          > Now I have a problem, if the grid is used in canvases, and height is
          > dynamic
          > based on other control positions, the header height is calculated in the
          > UpdateDisplayList further up the chain of the classes which DataGrid
          > extends
          > from. Without the headerheight, I can't calculate the best row size,
          > because I
          > dont know what space is available.
          >
          > (Interestingly for some reason, if there is no data in the grid, the
          > headerHeight inherits the row height initially, this is tagged in the
          > class as
          > to prevent bad behaviour from PDG?? This caused me an interesting problem
          > with
          > the grid continually invalidating its self because I was setting differing
          > rowheights each time because the header height differed)
          >
          > Am I missing a much easier way of achieving this? I am thinking of just
          > setting an explicit header height and leave my code as is, but it would be
          > preferable to make it all configurable/dynamic and still work.

          You might want to look at minheight. That won't help with having "partial"
          rows, but it will prevent it from going below that minimum. When the
          datagrid is resized, you may find that call validateNow() will make the rows
          redraw.


          • 2. Re: Datagrad, Rowheight depend on grid's height
            ice9_us
            I had partial rows and resolved my issue with help tool and hovering the mouse...
            not sure how that is going to work with touch screen...
            you may look funny hovering your finger :?)