datagrid variable row height and setting a max rowheight

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default datagrid variable row height and setting a max rowheight

    i'm looking for a way to allow variable row height to true but set a max row
    height and if it exceeds this height, a scrollbar would be accessible.

    the current scenario is that enabling variable row height would show
    everything but sometimes the text is too long and it takes longer to breeze
    through the list. on the otherhand, disabling would show only one line.

    i've tried using itemrenderers but to dynamically set the width and/or height
    of a text or textarea is a problem. its just sticking to one size

    any ideas?

    problemaPaDin Guest

  2. Similar Questions and Discussions

    1. Flexible Height of Datagrid
      Hi, I'm newbie in flex, I have a problem in datagrid. The contents of my datagrid comes from database, the problem is i wanted to have the height of...
    2. datagrid rowheight
      Hi Is it possible to set the rowheight of the datagrid. I have a paging grid but if there is say 2 entries then the height of each row expands...
    3. setting and retriving the correct text member height!
      how can i set and retrieve the correct height and width of a cast member? a lot of times I means tnx
    4. Datagrid Height
      I am trying to a datagrid into a small space and can't get it to conform. Any way to beat the minimum height of the datagrid so that it will show...
    5. DataGrid.Height
      I have a DataGrid in my WebForm. I set its Height propert to 1px because if I give it a big number and there's less records then expected, it...
  3. #2

    Default Re: datagrid variable row height and setting a max rowheight

    I've got a similar issue but I figure I'd append this thread instead of start
    my own. I would like to know if it's possible to have rows in Datagrids be
    different heights depending on the content in them (I need to use a custom
    itemRenderer for formatting reasons). I've got variableRowHeight set to true
    but I'm having no luck.

    Setting the itemRenderer's object height (the object itself is a container
    with two textboxes in them, one at the top as a "header" and one at the bottom
    that has "content" which will have varying heights) causes scrollbars to appear
    PER row. Getting rid of the height property causes an issue similar to the
    OP's issue, where all the row heights are the same (occasionally the rows
    collapse and I cant see my data anymore).

    I've even tried writing a function to manually increase the itemRenderer's
    height based on the height of the content textbox, but no luck there either.

    Finally, setting constraints on the content textbox to fit to the bottom of
    the container seems to be logical, but if the container itself isnt changing
    height in the datagrid, this solves nothing.

    Anybody have any insight?

    AashayD Guest

  4. #3

    Default Re: datagrid variable row height and setting a max rowheight

    I think you have to override set height() method in IR and there calculate
    maximum height allowed and if it is greater then some value - allow scroller.
    Otherwise - just resize the IR.

    Cheers,
    Dmitri.

    Mitek17 Guest

  5. #4

    Default Re: datagrid variable row height and setting a max row height

    On Apr 30, 10:38 pm, "Mitek17" <webforumsu...@macromedia.com> wrote:
    > I think you have to override set height() method in IR and there calculate
    > maximum height allowed and if it is greater then some value - allow scroller.
    > Otherwise - just resize the IR.
    >
    > Cheers,
    > Dmitri.
    I think this is the right idea since I did something similar for the
    column widths...I made a custom renderer for the header that uses an
    input box and put in an onchange handler and when the width of all the
    columns got greater than a certain threshold I turned autoScrollPolicy
    to auto from off. Now this was on the whole grid but I know you can
    do it on a column basis as well so the rows should work the same way.

    Chris
    Caffeinated Coder Guest

  6. #5

    Default Re: datagrid variable row height and setting a max rowheight

    The question is, how do you calculate maximum height on the fly? The height
    has to be determined by the content that is being loaded, and there's no way to
    know how much content is being loaded in that particular IR ahead of time. Is
    there a property of the text height that I can latch onto?

    The end-goal is to remove scrolling entirely within each IR. It's kinda silly
    to have scrolling elements inside a scrolling datagrid :)

    AashayD Guest

  7. #6

    Default Re: datagrid variable row height and setting a max rowheight

    Sorry, I don't understand your question - why do you need to know max height?

    Here is the example - this is my component which displays text. It tries to
    accommodate as much text as possible .if it reaches some limit -only then it
    start showing scrollbar. You need this if you use it as IR - as List becomes
    dysfunctional if item.height > list.height.



    package
    {
    import mx.controls.TextArea;
    public class ElasticTextArea extends TextArea
    {
    public function ElasticTextArea()
    {
    super();
    super.horizontalScrollPolicy = "off";
    super.verticalScrollPolicy = "off";
    super.editable = false;
    }

    override public function set text(val:String):void
    {
    super.verticalScrollPolicy = "off";
    textField.text = val;
    validateNow();

    //set height to the height of the text + 1 line
    height = textField.textHeight +
    textField.getLineMetrics(0).height;
    }

    override public function set height(value:Number):void
    {
    var l_iMeasureHeight:uint = textField.textHeight +
    textField.getLineMetrics(0).height;
    if (l_iMeasureHeight<= super.maxHeight)
    {
    super.height = l_iMeasureHeight;
    }
    else
    {
    super.height = super.maxHeight;
    super.verticalScrollPolicy = "on";
    }
    }

    override public function set maxHeight(value:Number):void
    {
    super.maxHeight = value;
    }

    override protected function updateDisplayList(unscaledWidth:Number,
    unscaledHeight:Number):void
    {
    height = textField.textHeight + textField.getLineMetrics(0).height;
    super.updateDisplayList(unscaledWidth, unscaledHeight);
    }
    }
    }

    PS. This thing is not suitable for printing - it is a whole different story
    with "Flex Printing Engine" (c) :)

    Cheers,
    Dmitri.

    Mitek17 Guest

  8. #7

    Default Re: datagrid variable row height and setting a max rowheight

    i did this instead:

    <mx:DataGridColumn id="notes" textAlign="left" headerText="Notes"
    dataField="Notes" wordWrap="true" editable="false">
    <mx:itemRenderer >
    <mx:Component>
    <mx:HBox maxHeight="75">
    <mx:Text text="{data.Notes}" width="100%" />
    </mx:HBox>
    </mx:Component>
    </mx:itemRenderer>
    <mx:itemEditor>
    <mx:Component>
    <mx:TextArea text="{data.Notes}" width="100%"/>
    </mx:Component>
    </mx:itemEditor>
    </mx:DataGridColumn>

    but a new problem arose.
    everytime i change the data in the arraycollection (i used pagination) the
    datagrid rows go back to a one-liner-row and until i edit it, thats when the
    datagrid refreshes it and resizes the rowheight.

    i think it has something to do with the updateDisplayList(). but i'm not sure.

    any ideas? help please...

    thanks

    problemaPaDin Guest

  9. #8

    Smile Re: datagrid variable row height and setting a max rowheight

    Quote Originally Posted by problemaPaDin View Post
    i'm looking for a way to allow variable row height to true but set a max row
    height and if it exceeds this height, a scrollbar would be accessible.

    the current scenario is that enabling variable row height would show
    everything but sometimes the text is too long and it takes longer to breeze
    through the list. on the otherhand, disabling would show only one line.

    i've tried using itemrenderers but to dynamically set the width and/or height
    of a text or textarea is a problem. its just sticking to one size

    any ideas?
    Try this ..... the datagrid size will be perfect height

    ADG.showHeaders = "false";

    var rwcnt = xmllist.length();// dataprovider.length

    ADG.rowHeight = 20;

    var rht = ADG.rowHeight;

    ADG.height = (rwcnt * rht) + 26;

    this is what i got solution to control the size of advanced datagrid

    --Mahesh Babu M
    maheshmb.213@gmail.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139