Announcement

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

    How to align titles on items in Dynamic forms when Top orientation is used?

    Version: martClient Version: SNAPSHOT_v11.0d_2016-03-14/LGPL Development Only[FONT=Arial, Verdana, sans-serif][COLOR=#000000] (built 2016-03-14) [/COLOR][/FONT]

    [FONT=Arial, Verdana, sans-serif][COLOR=#000000]Configuration: I'm programming SmartGWT on top of GWT using Eclipse development environment with Chrome browser using super dev mode

    How to set right-alignment when using text items in dynamic form which are set to use Top orientation?

    Problem seems simple enough, but I've tried all the usual suspects such as setTitleAlign(Alignment.RIGHT) on both the dynamic form and/or each item being added to the form, and titles always come out left-justified if setTitleOrientation(TitleOrientation.TOP) is set. See picture. I'd appreciate any clues anybody may have. Hopefully this can be done. Thanks for any help you can provide. - Jim W.[/COLOR][/FONT]

    Attached Files

    #2
    If this is for RTL (Right-To-Left) languages, you don't need to do anything, the orientation just flips when you are in RTL mode (see Internationalization overview).

    Otherwise you can use formItem.align:"right" to do this, but bear in mind, in anything other than the narrow case you've constructed in your screenshot, this usually looks weird. For example, the title text might end up on top of a FormItemIcon, or hint. Or, for controls that are smaller than their column, the title text might end up over empty space.

    Comment


      #3
      Thank you for responding to my query. This is not an internationalization issue. Each of the numeric values shown underneath each of the column titles are right-aligned in their boxes, so I would like the titles above them to also be right-aligned so there is a nice straight edge - visually - down the right-hand side of each of the columns. You mentioned using formItem.align:"right". Questions: 1 - I think this must be related to use of 'Attributes" which I haven't done yet, a link to a reference or a snippet would be greatly appreciated. 2 - from the name of the attribute "formItem.align" I would think this would apply to the contents of the TextItem below the title and not the title above.. Are you sure this attribute applies to the titles above the text items?

      What I currently have:

      Click image for larger version

Name:	ibad.png
Views:	270
Size:	6.1 KB
ID:	236462

      What I'd like instead:

      Click image for larger version

Name:	igood.png
Views:	273
Size:	5.8 KB
ID:	236463


      private TextItem makeTextItemOverAndUnder( String title, String prompt, int width )
      {
      TextItem retn = new TextItem();
      retn.setTitle(title);
      retn.setPrompt(prompt);
      retn.setValue("-");
      retn.setCanEdit(false);
      retn.setTitleOrientation(TitleOrientation.TOP);
      retn.setTitleAlign(Alignment.RIGHT); /* this appears to do nothing if setTitleOrientation() is set to TOP */
      retn.setTextAlign(Alignment.RIGHT);
      retn.setWidth(width);
      retn.setStartRow(false);
      retn.setShowTitle(true);
      return retn;
      } /* - has same symptom if setting alignments and orientation is done using form-wide DynamicForm proeprties instead of TextItem-specific properties */


      Again, thank you very much for responding to my query. - Jim W.

      Comment


        #4
        By FormItem.align we mean there is a FormItem API setAlign() - just standard Java Beans convention, no need to use custom attributes.

        As you'll discover from the docs, formItem.align will right align the entire formItem within it's column. But the result in this case is what you show in your screenshot. As we covered, this would potentially not look good in the presence of hints, FormItemIcons, etc.

        Comment


          #5
          THANK YOU. It worked nicely. I'm surprised I overlooked this method on the FormItem base class.

          Comment

          Working...
          X