4 Replies Latest reply on Apr 14, 2011 5:43 AM by MikeBoni

    DataGrid horizontalGridLines in wrong position

    MikeBoni

      Folks,

       

      I've got a problem with my DataGrid when I turn on horizontalGridLines. There are a couple cases where the grid lines are clearly being drawn in the wrong place. This only becomes visible when I have wordWrap and variableRowHeight both set to true.

       

      Most notably, I have one place where I open a popup window with a table and then scroll down to some row based on the user's selection. The alternating colors for the row backgrounds are drawn correctly. However, the horizontalGridLines are clearly misplaced. In fact, I can tell that the horizontalGridLines are being drawn as if the table was scrolled to the top, rather than to the row I'm interested in showing.

       

      As soon as you scroll the table manually, the grid lines are re-drawn in their correct position.

       

      I'm in the middle of transitioning from SDK 3.5 to 4.2, and the problem shows up in both environments.

        • 1. Re: DataGrid horizontalGridLines in wrong position
          tooMuchTrouble Level 3

          On 4/14/2011 12:31 AM, MikeBoni said:

           

          horizontalGridLines are being drawn as if the table was scrolled to the top,

          rather than to the row I'm interested in showing.

           

          i think that's been an issue since flex 2

           

          the only workaround i've come across (and i wish i could recall where) is to

          extend your Datagrid to include:

           

          override public function set verticalScrollPosition( value:Number ):void {

            drawLinesAndColumnBackgrounds(); // forces lines to be redrawn

            super.verticalScrollPosition = value;

          }

           

          won't stop this from happening but will put things to right as soon as the user

          stops scrolling.

          1 person found this helpful
          • 2. Re: DataGrid horizontalGridLines in wrong position
            MikeBoni Level 1

            That didn't quite fix it. However, reversing the order seems to solve my problem:

             

            override public function set verticalScrollPosition( value:Number ):void {

              super.verticalScrollPosition = value;

              drawLinesAndColumnBackgrounds(); // forces lines to be redrawn

            }

             

            Thanks for pointing me in the right direction.

            • 3. Re: DataGrid horizontalGridLines in wrong position
              tooMuchTrouble Level 3

              "solves" as in it doesn't happen in the first place or it corrects itself after the user stops scrolling?

              • 4. Re: DataGrid horizontalGridLines in wrong position
                MikeBoni Level 1

                "solves" meaning that the gridlines are now in the right place when I open the table pre-scrolled to a given row.  It also appears to solve the 2nd case, where the user scrolls a table and sometimes ends up with the lines in the wrong position.

                 

                It looks to me like a sequencing problem within the DataGrid class, it's just not making sure everything happens in the right order, so sometimes the grid lines are painted before the table is scrolled, and sometimes after. I think overriding the setter the way I did is going to cause redundant painting, but that's the price we have to pay for getting it right.