2 Replies Latest reply on Jan 5, 2011 8:27 AM by Gregory Lafrance

    How can I fix the height of  advance datagrid  depending upon the  number of rows.

    Pol-suma

      Hello,

      I have an advance datagrid with few rows in it. But the height of the grid is more than the number of rows...How can I fix the height to the number of rows. i.e If the number of rows are 5 then the height should be according to that.

       

      Can anybody please tell me a solution for this.

       

       

      Thanks,

      Suma.

        • 1. Re: How can I fix the height of  advance datagrid  depending upon the  number of rows.
          Sree_D Level 2

          You can try overriding updateDisplayList method in AdvancedDataGrid to set new height  which is calculated based on rows*height of each row.

          1 person found this helpful
          • 2. Re: How can I fix the height of  advance datagrid  depending upon the  number of rows.
            Gregory Lafrance Level 6

            Set rowCount equal to length of dataProvider:

             

            <?xml version="1.0"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
              <mx:Script>
                <![CDATA[
                  import mx.collections.ArrayCollection;
                  include "SimpleFlatData.as";
                ]]>
              </mx:Script>
              <mx:AdvancedDataGrid id="myADG" dataProvider="{dpFlat}"
                width="100%" rowCount="{dpFlat.length}">
                <mx:groupedColumns>
                  <mx:AdvancedDataGridColumn dataField="Region"/>
                  <mx:AdvancedDataGridColumn dataField="Territory"/>
                  <mx:AdvancedDataGridColumn dataField="Territory_Rep"
                    headerText="Territory Rep"/>
                  <mx:AdvancedDataGridColumnGroup headerText="Revenues">    
                    <mx:AdvancedDataGridColumn dataField="Actual"/>
                    <mx:AdvancedDataGridColumn dataField="Estimate"/>
                  </mx:AdvancedDataGridColumnGroup>    
                </mx:groupedColumns>
              </mx:AdvancedDataGrid>
            </mx:Application>
            

             

            [Bindable]
            private var dpFlat:ArrayCollection = new ArrayCollection([
              {Region:"Southwest", Territory:"Arizona", 
                  Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000}, 
              {Region:"Southwest", Territory:"Arizona", 
                  Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000},  
              {Region:"Southwest", Territory:"Central California", 
                  Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},  
              {Region:"Southwest", Territory:"Nevada", 
                  Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},  
              {Region:"Southwest", Territory:"Northern California", 
                  Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000}, 
              {Region:"Southwest", Territory:"Northern California", 
                  Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000},  
              {Region:"Southwest", Territory:"Southern California", 
                  Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000}, 
              {Region:"Southwest", Territory:"Southern California", 
                  Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000}
            ]);
            


            If this post answers your question or helps, please mark it as such. Thanks!

            http://www.stardustsystems.com
            Adobe Flex Development and Support Services