7 Replies Latest reply on Mar 24, 2007 9:43 AM by rwtemple

    DataGrid bug and solution

    rwtemple
      When a DataGrid has at least one non-text renderer and has more rows then are visible, sometimes the last visible row is drawn outside the boundary of the DataGrid, onto whatever is under it.

      Because Adobe was kind enough to provide us with the mx source code, I found the bug in the addClipMask function of ListBase.as:

      At the very end of the of the function, the following code is where the bug is:


      var numColumns:int = lastRowItems.length;
      var rowY:Number = lastRowInfo.y;
      var rowWidth:Number = listContent.width;
      var rowHeight:Number = listContent.height - lastRowInfo.y;
      for (var i:int = 0; i < numColumns; i++)
      {
      var item:DisplayObject = lastRowItems
      ;
      var yOffset:Number = item.y - rowY;
      if (item is UITextField)
      item.height = rowHeight - yOffset;
      else
      item.mask = createItemMask(0, rowY + yOffset, rowWidth, rowHeight - yOffset);
      }


      Sometimes, yOffset is greater then rowHeight, and as a result, so the code tries to set the height of the UITextField and
      the mask size of non text items to a negative number which is invalid. The corrected code follows:


      var numColumns:int = lastRowItems.length;
      var rowY:Number = lastRowInfo.y;
      var rowWidth:Number = listContent.width;
      var rowHeight:Number = listContent.height - lastRowInfo.y;
      for (var i:int = 0; i < numColumns; i++)
      {
      var item:DisplayObject = lastRowItems
      ;
      var yOffset:Number = item.y - rowY;
      var newHeight:Number = Math.max(rowHeight - yOffset, 0);
      if (item is UITextField)
      item.height = newHeight;
      else
      item.mask = createItemMask(0, rowY + yOffset, rowWidth, newHeight);
      }