views:

332

answers:

2

Hi!

I have 2 questions about flex datagrids:

  1. How can I scroll it automatically to the bottom when new portion of data arrived to it (e.g. I added new items)
  2. Strange, but seems it doesn't scroll when I use scrolling wheel, is there any trick about it (especially for mac Users)

Thanks in advance


Some changes:

public function scroll():void
{   
    trace(chatboard.maxVerticalScrollPosition);
    chatboard.verticalScrollPosition = chatboard.maxVerticalScrollPosition;
}

<mx:TextArea id="chatboard" x="10" y="10" width="310" height="181" text="{chatMessages}" editable="false" verticalScrollPolicy="on" resize="scroll()"/>

But actually it don't help. The text area is not autoscrolled :(


Seems that 1) scroll is not called after new string is added to chatMessages

A: 

1) dataGrid.verticalScrollPosition=dataGrid.maxVerticalScrollPosition

mazgalici
+1  A: 

I find here that the mouse wheel scrolls the text area by default. Are you looking for a different behavior?

As far as skipping to the end goes:

in your TextArea wire up to the updateComplete and it seems to work as you would like:

 <mx:TextArea id="textArea1" liveScrolling="true" updateComplete="textArea1_Changed(event);" />

then

  private function textArea1_Changed(event:Event):void {textArea1.verticalScrollPosition = textArea1.maxVerticalScrollPosition;}

finally, you can test with something like:

  private function btnClick(e:Event):void{textArea1.text += new Date().getTime().toString() + "\n";}
Jon.Stromer.Galley
This solution works! I mean that the box is autoscrolled, as I needed.(don't know why wheel scrolling is not working) :(Anyway thanks!
Oleg Tarasenko