SmartGwt get VLayout height after add members

允我心安 提交于 2019-12-11 13:23:14

问题


I have problem a with getting VLayout height after I add a member to it

VLayot layout = new VLayout();

in presenter I have code

display.getAnswerPanel().removeMembers(display.getAnswerPanel().getMembers());

which clear all members, and I add another (I have buttons, when I clik them, it clears all VLayout and adds new members)

layout.addMember(new Button("Example"));

I need to get offsetHeight of this VLayout on start and everytime I click the button, my problem is that in first time when I load the page, my `offsetHeigh is 1px, each next time when I click button is ok, it shows me the correct value. Can someone help me?

I tried to use this code

scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
    layout.getOffsetHeight();
}

but the situation is the same, First time I don't have the correct value.


回答1:


we can get the height and width of any widget only after the widget is being loaded or on button click.




回答2:


Scheduler#scheduleDeferred() executes at the end of the GWT loop, so there's still no time for the layout to update either. I guess there's not much you can do besides using the traditional timer hack (in case any reader is in doubt, yes, I meant using setTimeout() or Scheduler.get().scheduleWithFixedDelay(cmd, 200) ).



来源:https://stackoverflow.com/questions/14318080/smartgwt-get-vlayout-height-after-add-members

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!