Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT - show/hide <tr> in a HTMLPanel

Tags:

html-table

gwt

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>
<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!!!

like image 493
david Avatar asked Jan 23 '11 00:01

david


2 Answers

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

like image 162
Tassos Bassoukos Avatar answered Oct 28 '22 06:10

Tassos Bassoukos


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)

like image 5
sjakubowski Avatar answered Oct 28 '22 08:10

sjakubowski