Datagrid and variable height

Posted on 2008-11-05
Last Modified: 2013-11-11
I am trying to dynamically adjust the height of each row depending on the amount of text there is. Is this something only AS3 or Flex can do? Or am I missing something?
function dataGridFunction() {

	var characters:Array = new Array(new Array("01", "Jerry Jerry Jerry Jerry Jerry", "Seinfeld Seinfeld Seinfeld Seinfeld Seinfeld Seinfeld Seinfeld Seinfeld Seinfeld Seinfeld"), new Array("02", "Elaine", "Benes"), new Array("03", "Cosmo", "Kramer"), new Array("04", "Jocopo", "Peterman"), new Array("05", "Lloyd", "Braun"), new Array("06", "Estelle", "Costanza"), new Array("06", "George", "Costanza"), new Array("08", "Frank", "Costanza"), new Array("09", "David", "Puddy"), new Array("10", "Mickey", "Abbott"), new Array("11", "Morty", "Seinfeld"), new Array("12", "Helen", "Seinfeld"));


	for (var i:Number = 0; i<characters.length; i++) {

		var id:String = characters[i][0];// I added this field

		var firstName:String = characters[i][1];

		var lastName:String = characters[i][2];

		dataGridMain.addItem({ID:id, First:firstName, Last:lastName});



		dataGridMain.variableRowHeight = true;

	dataGridMain.wordWrap = true;




	dataGridMain.setStyle("alternatingRowColors",["0xF0F0F0", "0xFFFFFF"]);


	dataGridMain.setStyle("selectionColor","0x5ec40b");// was 0xFFF97D





Open in new window

Question by:msukow
    LVL 39

    Expert Comment

    i think what you're looking for is the CellRenderer.
    have a look in the help file - there's explanations on how it works and some samples on how to create multiline cells so i think that should resize according to the content.
    haven't tried it myself but its worth a shot.
    LVL 39

    Accepted Solution

    oh wait, i just read this in the help file.
    as you know the DataGrid extends the list

    " The following are some fundamental assumptions and requirements that Adobe used when developing the List class:

    Lists have uniform row heights.
    Every row must be the same height; the height can be set during authoring or at runtime.

    Lists must scale to thousands of records.
    Lists don't measure text.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
    In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
    The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
    The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now