Announcement

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

    Hide FormItem colon when title is empty

    I want the colon for FormItems that do have a valid title.
    But I want the FormItem suffix to be suppressed when the title is empty/null (see attachment).

    I guess I could turn title suffixes off and then add the colon myself as part of the title, but that's quite a bit of work... any "simple" way to accomplish this? Ideally, I'd be able to set this globally or at least on a per FormItem basis...

    Context menu
    1.
    SmartClient Version: v10.0p_2015-06-24/LGPL Development Only (built 2015-06-24)
    GWT 2.5.0

    2. browser(s) and version(s) involved
    Firefox 19: fails
    Chrome 43: passes
    IE 9: passes

    Sample code if applicable
    Code:
    public class TestSetTitleSuffix implements EntryPoint {
    
      /**
       * The EntryPoint interface
       * Upgrading SmartGWT from 4.0-2013-11-30 to 5.0-2015-06-25
       */
      public void onModuleLoad () {
    
        final TextItem item1 = new TextItem ();
        item1.setTitle ("Name");
        item1.setValue ("Title is: Name");
        
        final TextItem item2 = new TextItem ();
        item2.setTitle ("");
        item2.setValue ("Title is: <empty string>");
        
        final TextItem item3 = new TextItem ();
        item3.setTitle (null);
        item3.setValue ("Title is: null");
        
        final TextItem item4 = new TextItem ();
        item4.setTitle (null);
        item4.setValue ("Title is: <not set>");
    
        final DynamicForm form = new DynamicForm ();
        // form.setTitleSuffix ("");
        // form.setRequiredTitleSuffix ("");
        form.setFields (item1, item2, item3, item4);
        form.draw ();
      }
    }
    Attached Files

    #2
    There's no solution?

    Comment


      #3
      Hi mj2223,

      workaround could be to use more DynamicForm (at least one for the ones with title and one for the ones w/o title and a ValuesManager.
      But that's not very nice IMHO.
      How about setShowTitle(false), setStartRow(false) for the FormItems without title and SpacerItems with setStartRow(true) in front of each one?

      Best regards
      Blama

      Comment


        #4
        Hello,

        Thank you for taking the time to reply my question.

        Finally I have given up. I have removed the title suffixes for all the form items.

        We may be considering another framework thats more flexible for our project.

        Rgds,
        MJ2223

        Comment


          #5
          setShowTitle(false) is the right way to hide a title. This is covered prominently in the Form Layout overview and touched on in the QuickStart.

          So, this is a simple and well documented approach and not a workaround, nor do we see how this could be considered a lack of flexibility.

          Comment


            #6
            Hello Isomorphic,

            Thank you for your reply.. I wanted to have some flexibility for the prefix. I did not want to remove the prefix from all the form items, but only one. (example a date range : Date from : | Field From | - | Field To| .) This is achievable though the widget DateRangeItem, but for some reason , I cannot communicate correctly with my controller and service when using DateRangeItems. So I had to use 2 DateItems instead.

            There's also is a lack of examples for the different widgets of smartGWT. (the showcase is not enough). Also performance degrades badly when using functionalities for listgrid such as CreateRecordComponent. Is this going to be reworked in the next version of smartGWT?

            Thank you,
            MJ2223.

            Comment


              #7
              DateRangeItem achieves its display of titles and colons without any sort of prefix/suffix hacking, just using the documented setShowTitle() approach. So again we're not seeing any kind of use case that isn't addressed or isn't prominently documented.

              As far as your attempt to make your own DateRangeItem, there are a lot of little details to get right, so you are probably better off figuring out your issue with integrating with your controller rather than rebuilding this UI control.

              If there is a widget that doesn't have sufficient samples, please point it out. We already have far more samples, with far more depth shown, than any other framework, but we are always adding more, and if you've identified a real need we'd happily address it.

              Finally, see the docs for showRecordComponents - it explains performance expectations, how to get the best performance, and scenarios for which recordComponents are not the best solution and alternative APIs to use in that case.

              Comment


                #8
                Hello Isormorphic,

                Thank you for your reply.

                For the docs for showRecordComponents, could you give me the link? Are you refering to the java documents? (ie. https://www.smartclient.com/smartgwt...rdComponents--)

                Rgds,
                MJ2223

                Comment


                  #9
                  Yes, that's the one.

                  Comment


                    #10
                    Hi Isomorphic I am running into the same issue mj2223 had regarding titles and following colons. The issue is the alignment of the items inside the DynamicForm.

                    Please see attached images for better understanding:

                    Alignment Issue: We don't want titles for these formItems
                    Click image for larger version

Name:	issue.png
Views:	172
Size:	12.3 KB
ID:	269210

                    Solution: Just need to remove the colons
                    Click image for larger version

Name:	solution.png
Views:	176
Size:	14.1 KB
ID:	269209

                    Let me know if you need anything else.

                    Bests,

                    Comment


                      #11
                      Not the same issue. mj2223 was using setTitle(null) instead of just setShowTitle(false), so that left a dangling colon, which setShowTitle(false) gets rid of.

                      Your issue is that you are using titleOrientation:"vertical" and you like the placement of the control when the title is present, but rather than ask for that placement (which is done via formItem.valign:"bottom") you are just trying to hack things by setting a blank title. So just use valign instead of trying to use an invisible title for placement.


                      Comment


                        #12
                        Awesome, you nailed it!

                        Thanks for the help and quick response time!

                        Comment

                        Working...
                        X