0

Issue with width change on a groupbox

asked 2016-05-06 18:29:25 +0800

caiofilipemr gravatar image caiofilipemr
5 2

Hello everyone!

I need a help with a width change issue. I change the width of the groupbox in the btn onClick event, but the listbox inside of the groupbox don't resize, so a part is cutted.

I did a fiddle, but I won't be able to publis, the name is: Hflex issue on the change.

Here is the .ZUL

<zk>

<window border="normal" title="hello" apply="pkg$.TestComposer">

<groupbox id="grpbx" width="750px">
  <caption label="Groupbox" style="color:#006699; font-weight: bold" />
  <listbox height="213px" hflex="1">
    <listhead>
      <listheader width="30px"/>
      <listheader label="test" width="100px"/>
      <listheader width="120px" />
      <listheader width="170px" />
      <listheader   width="125px" />
      <listheader width="90px" />
      <listheader width="90px" />
    </listhead>
    <listitem>
      <listcell label="foo"/>
      <listcell label="foo"/>
      <listcell label="foo"/>
      <listcell label="foo"/>
      <listcell label="foo"/>
      <listcell label="foo"/>
      <listcell label="foo"/>
    </listitem>
  </listbox>
  </groupbox>

  <button id="btn" label="Click me to see the error" />

</window> </zk>

Here is the .JAVA

import org.zkoss.zk.ui.*;
import org.zkoss.zk.ui.event.*;
import org.zkoss.zk.ui.util.*;
import org.zkoss.zk.ui.ext.*;
import org.zkoss.zk.au.*;
import org.zkoss.zk.au.out.*;
import org.zkoss.zul.*;

public class TestComposer extends GenericForwardComposer{

  private Groupbox grpbx;
  private boolean bool = true;

public void doAfterCompose(Component comp) throws Exception {
    super.doAfterCompose(comp);

}

public void onClick$btn(Event e) throws InterruptedException{
      if (bool == true) {
        grpbx.setWidth("650px");
      } else {
        grpbx.setWidth("750px");
      }                  
      bool = !bool;
}
}

Thanks in advance!

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2016-05-06 21:34:43 +0800

Darksu gravatar image Darksu
1991 1 4

Hello caiofilipemr,

You have to use percentages instead of fixed pixels for it to work properly (dont forget parent-child relations for percentages).

Also you can use sizedByContent="true" for auto setting the column sizes.

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2016-05-09 11:34:24 +0800

caiofilipemr gravatar image caiofilipemr
5 2

updated 2016-05-09 14:24:24 +0800

Thanks for the answer Darksu, but I don't get it, I tried to do this: <groupbox id="grpbx" width="50%">, <listbox height="213px" width="100%"> and

public void onClick$btn(Event e) throws InterruptedException{
          if (bool == true) {
            grpbx.setWidth("50%");
          } else {
            grpbx.setWidth("35%");
          }                  
          bool = !bool;
    }

What am I doing wrong ?

UPDATE: In the first example, if I close and then open the groupbox the listbox resize and fit correctly.

link publish delete flag offensive edit
0

answered 2016-05-10 18:09:48 +0800

caiofilipemr gravatar image caiofilipemr
5 2

I figured out! I don't know if is the best way neither if is the right way, but works fine for me. I add this line grpbx.invalidate() in

public void onClick$btn(Event e) throws InterruptedException{
          if (bool == true) {
            grpbx.setWidth("650px");
          } else {
            grpbx.setWidth("750px");
          } 
          grpbx.invalidate(); //here
          bool = !bool;
    }

I hope this helps someone. The fiddle is 4-Hflex-issue-on-the-change. I can't post links yet.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2016-05-06 18:29:25 +0800

Seen: 26 times

Last updated: May 10 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More