PDA

View Full Version : Textarea not scroll to bottom



yitachi
6 Jan 2011, 8:07 AM
Hi,
I used com.extjs.gxt.ui.client.widget.form.TextArea



txtConsole= new TextArea();
txtConsole.setReadOnly(true);
container.add(txtConsole);


and setting its value and trying to set scroll to bottom;



txtConsole.setValue(message);
txtConsole.setCursorPos(message.length());
txtConsole.getElement().setScrollTop(txtConsole.getElement().getScrollHeight());


But scroll is still at the top of the textarea.
I am using GWT 2.1 and GXT 2.2.1.

What should I do to send scroll to bottom?

Thanks.

sven
6 Jan 2011, 1:27 PM
This wont work. You need to get the element after rendering. getElement() before rendering will return you a dummy element. Also getElement returns the wrong one. It will be getElement().getFirstChildElement();

yitachi
6 Jan 2011, 11:05 PM
Thank you very much,
it works.


txtConsole.getElement().getFirstChildElement().setScrollTop(txtConsole.getElement().getFirstChildElement().getScrollHeight())