开发者

GWT - show/hide <tr> in a HTMLPanel

I have a HTMLPanel with a <table> inside. I want to show/hide a <tr> from the the java code.

I tried to put the <tr> inside other HTMLPanel and to hide the Panel. Something like this:

...
<tr>
  ...
</tr>开发者_StackOverflow中文版
<g:HTMLPanel ui:field="name">
    <tr>
    ...
    </tr>
</g:HTMLPanel>
<tr>
  ...
</tr>

code:

name.setVisible(false);

and it works, but it causes a strange behaviour in the presentation.

How could I do this???

Thx a lot!!!


Use an @UiField TreeRowElement rowName with the HTML being ...<tr ui:field="rowName">...</tr>.... Then use the TreeRowElement to show/hide that row.


Expanding upon @Tassos answer:

Java

@UiField TableRowElement expanded;

boolean exp=false;

    expandme.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent clickevent) {
            if(exp){
                expanded.getStyle().setDisplay(Display.NONE);
            } else {
                expanded.getStyle().clearDisplay(); //took a little while to find.
            }
            exp = !exp;
        }
    });

HTML:

<tr ui:field="expanded">   

Where expandme is any element that you can attach a click handler to, (ex Anchor,Button,etc)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜