2 Replies Latest reply on Jul 5, 2011 3:00 AM by dinko_ivanov

    Spark DataGrid row padding

    dinko_ivanov Level 1

      Hello guys,

       

      Could someone advise how to control top/bottom padding of rows in the Spark DataGrid control?

       

      Image2.jpg

      I need to "squeeze" the rows a bit. I use the default item renderer.

       

      Thanks in Advance!

       

      Regards,

      Dinko

        • 1. Re: Spark DataGrid row padding
          kevinklin Adobe Employee

          Hi Dinko,

           

          There are two ways to accomplish this:

           

          1) Use a custom GridItemRenderer with a Label and adjust the padding that way. Note that this will be less performant when compared to the default renderer. For example:

           

          <s:DataGrid>
              <s:itemRenderer>
                  <fx:Component>
                      <s:GridItemRenderer clipAndEnableScrolling="true">
                          <s:Label text="{label}" left="5" right="5" top="2" bottom="2" />
                      </s:GridItemRenderer>
                  </fx:Component>
              </s:itemRenderer>
          ...
          </s:DataGrid>
          

           

          2) Make your own version of DefaultGridItemRenderer and adjust the LEFT_PADDING, RIGHT_PADDING, TOP_PADDING, and BOTTOM_PADDING constants to what you would like them to be. This is slightly more complicated because you will need copy, paste, and clean up a lot of code. However, I did some of the work for you in the attachment (CustomDefaultGridItemRenderer.as). You just need to change the package, specify it as the item renderer on your DataGrid and change the padding values. Also, there's a bug for this here: https://bugs.adobe.com/jira/browse/SDK-28411.

           

          I would go with number 1 for ease of use. The performance degradation shouldn't be too much for most use cases. Hope this helps.

          -Kevin

          1 person found this helpful
          • 2. Re: Spark DataGrid row padding
            dinko_ivanov Level 1

            Hello Kevin,

            I took the first suggestion, and it worked great. I addition I added maxDisplayedLines="1" to the label and also a custom header renderer and I managed to achieve a condensed look of the Table.

             

            Thanks!

             

            Dinko