Ext GWT - 文本区域不滚动到底部

发布于 2024-10-10 20:23:55 字数 463 浏览 0 评论 0 原文

我使用 com.extjs.gxt.ui.client.widget.form.TextArea

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

并设置其值并尝试将滚动设置到底部;

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

但滚动仍然位于文本区域的顶部。 我正在使用 GWT 2.1 和 GXT 2.2.1。

我应该怎么做才能将滚动发送到底部?

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

走走停停 2024-10-17 20:23:55

我已经找到了解决方案并且它有效

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

根据下面的描述;

需要获取后面的元素
渲染。之前的 getElement()
渲染将返回一个虚拟元素。
getElement 也返回错误的元素。
这将是
getElement().getFirstChildElement();

I've found the solution and it works

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

According to below description;

Need to get the element after
rendering. getElement() before
rendering will return a dummy element.
Also getElement returns the wrong one.
It will be
getElement().getFirstChildElement();

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文