Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    TextItem.setWidth ("*") + setShowTitle (false) = default width

    I want a TextItem to take all the space available to the form.
    Calling textItem.setWidth ("*") works.
    However, when I also call textItem.setShowTitle (false), then the item width shrinks down to 96 (I think).
    Any ideas?

    FF 6.0.2
    SmartGWT 3.1p-2012-11-23
    SmartClient Version: v8.3p_2012-11-23/LGPL Development Only (built 2012-11-23)

    Code:
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.Version;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.layout.VLayout;
    import com.smartgwt.client.widgets.IButton;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.core.client.GWT;
    
    public class WideTextItem implements EntryPoint {
    
      /**
       * The EntryPoint interface
       */
      public void onModuleLoad () {
    
        // test
        SC.showConsole ();
        GWT.log ("GWT version: " + GWT.getVersion ());
        GWT.log ("SmartGWT version: " + Version.getVersion ());
        GWT.log ("SmartGWT buildDate: " + Version.getBuildDate ());
        GWT.log ("SmartGWT major-minor-patch: " + Version.getMajor () + "-" + Version.getMinor () + "-" + Version.getPatch ());
        GWT.log ("SmartGWT SC: " + Version.getSCVersionNumber ());
    
        // TextItem does take "*" as expected
        final DynamicForm form1;
        {
          // text item
          final TextItem textItem = new TextItem ();
          // textItem.setTitle ("");
          textItem.setRequired (true);
          textItem.setWidth ("*");
          textItem.setShowTitle (true);
      
          // form
          final DynamicForm form = new DynamicForm ();
          form.setBackgroundColor ("red");
          form.setIsGroup (true);
          form.setGroupTitle ("setShowTitle (true)");
          form.setItems (textItem);
          form1 = form;
        }
        
        // setShowTitle (false), and TextItem no longer takes "*"
        final DynamicForm form2;
        {
          // text item
          final TextItem textItem = new TextItem ();
          // textItem.setTitle ("");
          textItem.setRequired (true);
          textItem.setWidth ("*");
          textItem.setShowTitle (false);
      
          // form
          final DynamicForm form = new DynamicForm ();
          form.setBackgroundColor ("yellow");
          form.setIsGroup (true);
          form.setGroupTitle ("setShowTitle (false)");
          form.setItems (textItem);
          form2 = form;
        }
        
        // same as 2 plus hacks
        final DynamicForm form3;
        {
          // text item
          final TextItem textItem = new TextItem ();
          // textItem.setTitle ("");
          textItem.setRequired (true);
          textItem.setWidth ("*");
          textItem.setShowTitle (false);
          textItem.setTitleStyle ("visibility:hidden;");
          
          final TextItem textItem2 = new TextItem ();
          textItem2.setTitle ("Placeholder");
      
          // form
          final DynamicForm form = new DynamicForm ();
          form.setBackgroundColor ("green");
          form.setIsGroup (true);
          form.setGroupTitle ("setShowTitle (false) + placeholder item");
          form.setItems (textItem, textItem2);
          form3 = form;
        }
    
        // layout
        final VLayout layout = new VLayout ();
        layout.setBackgroundColor ("brown");
        layout.setWidth (600);
        layout.addMember (form1);
        layout.addMember (form2);
        layout.addMember (form3);
        layout.addMember (new IButton ("Hi"));
        layout.draw ();
      }
    }
    Attached Files

    #2
    Default colWidths are [titleWidth, "*"]. By setting showTitle:false you've moved your TextItem into the first column, and the default titleWidth is 100, minus 4 for cellPadding:2 times 2 = 96.

    See the FormLayout overview for how to control all of this.

    Comment


      #3
      I did before posting & testing:
      http://www.smartclient.com/smartgwte...ormLayout.html

      Things I tried / am trying:
      1. textItem.setShowTitle (false) and textItem.setWidth ("*") does not do what I expected
      2. form.setColWidths ("0", "*") does not work for me because the title is painted anyway
      3. form.setTitleSuffix ("") seems promising, but then calling textItem.setRequired (true) puts the colon right back
      4. textItem.setCellStyle ("displayNone"), which may be a stylename, does the 96 px thing (pushes the cell into the title location)
      5. form.setNumCols (1) and textItem.setWidth ("*") looks promising

      Lots of combos to check-out I guess...

      Comment

      Working...
      X