GWT - 在呈现单元格后获取 AbstractCell 内元素的大小

GWT - Get size of element inside AbstractCell after cell is rendered

有没有办法在呈现单元格时自动获取 AbstractCell 中元素的大小?

我正在渲染的单元格包含一个可以通过应用折叠的段落

.collapsed {
    overflow: hidden;
    display: block;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-height: 60px;
}

并通过删除折叠样式进行扩展。 根据段落是否折叠,分别使用 css.

添加 "read more" / "read less" 锚点

但是,当段落没有溢出时,它仍然显示我不想显示的 "read more" 锚点,因为没有更多内容可读。

AbstractCell 没有 onLoad() 或 onRander() 函数,那么有没有其他方法可以在加载段落后获取段落的大小?

也欢迎就如何解决此问题提出任何其他建议。

更新 table 后,您可以遍历所有单元格并获取其内容的宽度。请记住将其包装到调度程序中。否则你可能会得到全零,因为这段代码执行得太快了——在浏览器有机会渲染单元格之前。

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            // update your cells
        }
    });

您可以阅读有关调度程序的更多信息here