0 Replies Latest reply on Oct 14, 2009 1:12 PM by TS_Lindsey

    Stretched GridItems - need help

    TS_Lindsey

      Untitled-1.jpg


      For some reason, this Grid wants to pad out its GridItem children by the same number of pixels to fit the overal width, and completely ignores any percentWidth values assigned to GridItems.

      What I want to do is make the GridItems holding the PieCharts and those grey Texts only as big as the stuff in them, while only the empty GridItems on the outside stretch to make up the difference.  Attempts to percentWidth the empty GridItems does nothing, and attempts at convoluted minwitdhing messes up the grid even more.

       

      I assume I've missed something inceredibly obvious.

       

      here is the part of the code that isn't working right:

      commentsArea is a 443x573 VBox, and questionPieRender just returns an 80x80 piechart

       

                     private function questionPie():void
                     {
                          var grid:Grid=new Grid()
                          grid.setStyle("verticalGap", 0);
                          grid.setStyle("horizontalGap", 0);
                          grid.verticalScrollPolicy="off";
                          grid.horizontalScrollPolicy="off";
                          grid.autoLayout=false;
      
                          for (var num:Number=1; num <= 12; num++)
                          {
                               var gridRow1:GridRow=new GridRow();
                               var gridRow2:GridRow=new GridRow();
                               var gridRow3:GridRow=new GridRow();
                               var labelGridItem:GridItem=new GridItem();
                               var subLabel1GridItem:GridItem=new GridItem();
                               var subLabel2GridItem:GridItem=new GridItem();
                               var pie1GridItem:GridItem=new GridItem();
                               var pie2GridItem:GridItem=new GridItem();
                               var legend1GridItem:GridItem=new GridItem();
                               var legend2GridItem:GridItem=new GridItem();
                               var legend3GridItem:GridItem=new GridItem();
                               var label:Text=new Text();
                               var subLabel1:Text=new Text();
                               var subLabel2:Text=new Text();
                               var legend1:Text=new Text;
                               var legend2:Text=new Text;
                               var legend3:Text=new Text;
                               var pie1:PieChart;
                               var pie2:PieChart;
                               var padding1:GridItem=new GridItem;
                               var padding2:GridItem=new GridItem;
                               var padding3:GridItem=new GridItem;
                               label.text=QUESTIONS_ARR[num - 1];
                               subLabel1.text="bleh";
                               subLabel2.text="also bleh";
                               pie1=questionPieRender(num);
                               pie2=questionPieRender(num);
                               legend1.htmlText="1\n2\n3\n4\n5";
                               if (num != 12)
                               {
                                    legend2.htmlText="<p align=\"center\"><font color=\"#10c010\">Str. Agree</font></p>"
                                         + "<p align=\"center\"><font color=\"#ffff00\">Agree</font></p>"
                                         + "<p align=\"center\"><font color=\"#ffa500\">Disagree</font></p>"
                                         + "<p align=\"center\"><font color=\"#e00000\">Str. Disagree</font></p>"
                                         + "<p align=\"center\"><font color=\"#808080\">N/A</font></p>";                         }
                               legend3.htmlText="1\n2\n3\n4\n5";
                               label.width=commentsArea.width - 16;
                               labelGridItem.addChild(label);
                               subLabel1GridItem.addChild(subLabel1);
                               subLabel2GridItem.addChild(subLabel2);
                               grid.addChild(gridRow2);
                               grid.addChild(gridRow3);
                               pie1GridItem.addChild(pie1);
                               pie2GridItem.addChild(pie2);
                               legend1GridItem.addChild(legend1);
                               legend2GridItem.addChild(legend2);
                               legend3GridItem.addChild(legend3);
                               gridRow1.addChild(labelGridItem)
                               gridRow2.addChild(padding1);
                               gridRow2.addChild(subLabel1GridItem);
                               gridRow2.addChild(padding2);
                               gridRow2.addChild(subLabel2GridItem);
                               gridRow2.addChild(padding3);
                               gridRow3.addChild(pie1GridItem);
                               gridRow3.addChild(legend1GridItem);
                               gridRow3.addChild(legend2GridItem);
                               gridRow3.addChild(legend3GridItem);
                               gridRow3.addChild(pie2GridItem);
                               grid.addChild(gridRow1);
                               grid.addChild(gridRow2);
                               grid.addChild(gridRow3);
                               labelGridItem.colSpan=7;
                               subLabel1GridItem.colSpan=2;
                               subLabel2GridItem.colSpan=2;
                               padding1.rowSpan=2;
                               padding3.rowSpan=2;
                               legend1GridItem.setStyle("backgroundColor", "#e0e0e0")
                               legend2GridItem.setStyle("backgroundColor", "#e0e0e0")
                               legend3GridItem.setStyle("backgroundColor", "#e0e0e0")
                          }
                          commentsArea.addChild(grid);
                     }