7 Replies Latest reply on Jul 15, 2010 4:29 PM by Flex harUI

    Auto Height DataGrid Columns

    icytags

      Im trying to make a datagrid that when you enter more text then a column can hold it will automatically expand the column. I've found variableRowHeight in DataGrid but i cant figure out how i specifically tell it what size to make specific columns. Has anyone ever done anything like this before? any help is very much appreciated, thanks!

        • 1. Re: Auto Height DataGrid Columns
          Flex harUI Adobe Employee

          How to make the row grow as you edit it is an unsolved problem and expected

          to be hard.  If the data gets entered externally, then it is up to the

          renderer to report the correct measuredHeight based on the content and the

          DG will expand the row as needed.

          • 2. Re: Auto Height DataGrid Columns
            icytags Level 1

            Ok, im thinking that i can make a textArea auto resize the way i want so could i put a textArea as itemRenderer? the only problem im seeign with this is im populating my dataGrid with a XML file as dataProvider, how would i go about getting it to pass that information into the textArea itemRenderer??

            • 3. Re: Auto Height DataGrid Columns
              Flex harUI Adobe Employee

              Unless you need scrollbars and borders, the default renderer will do just

              fine.  Set wordWrap=true and variableRowHeight=true.

              • 4. Re: Auto Height DataGrid Columns
                icytags Level 1

                Ok now we're getting somewhere! Im able to accomplish making the rows grow in size depending on how much text is inside by removing the datagrids Height property. When i do this i get a dataGrid that goes all the way to the bottom of view and has many rows inside of it (all near hairline height) , but i do need to be able to tell it how big the dataGrid should initially be as well as how many rows to show and their initial size, is this possible? ive included code below

                 

                   <mx:DataGrid width="965"  textAlign="center" wordWrap="true" variableRowHeight="true"  sortableColumns="false" verticalScrollPolicy="off" id="s0" dataProvider="{XMLData}" editable="true" color="#000000" borderColor="#000000">

                       <mx:columns>

                           <mx:DataGridColumn headerText="Stufft" dataField="stuff"/>

                       </mx:columns>

                   </mx:DataGrid>

                • 5. Re: Auto Height DataGrid Columns
                  Flex harUI Adobe Employee

                  It shouldn't matter whether you set height or not.  The default renderers

                  should be handling it correctly.  If you can make a complete example in

                  about 20 lines, post it.

                  • 6. Re: Auto Height DataGrid Columns
                    icytags Level 1

                    well the problem is im trying ot set the height to only show 1 row (55px) and then when it expands the row to fit the multilined text it works but its not visible since the DG is only 55px (allowing viewing area for 1 row)

                    • 7. Re: Auto Height DataGrid Columns
                      Flex harUI Adobe Employee

                      There are past threads on how to size a DG.  It involves using

                      measureHeightOfItems and factoring in viewMetrics.