Announcement

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

    RichTextItem without top controls

    Hi,

    How can I hide the format controls displayed by RichTextItem?

    I have a grid with cells that contain HTML and need to make the text editable but without displaying the RichTextItem toolbar.

    I'm using SmartGWT 5.0p, built on Mar 14, 2015.

    Regards,
    Rodolfo

    #2
    See the docs for RichTextItem and it's subcomponent RichTextEditor, specifically "controlGroups" and related properties.

    Comment


      #3
      Already checked docs

      Hi,

      I already checked javadoc for RichTextItem and couldn't find a way to get access to the underlying RichTextEditor editor.

      Also, the javadoc for RichTextEditor doesn't mention how to get existing controls in order to hide them. The docs says that GetToolbar() always return null ...

      I tried this:

      myRichItem.setControlGroups(new String[]{});

      but it still renders an empty grey bar at the top that uses a lot of screen space.

      Would it be possible to have a couple of lines of code that point me in the right direction?

      Regards,
      Rodolfo

      Comment


        #4
        Since you're hiding all of the controlGroups, you also want to hide the RichTextEditor.toolArea AutoChild.

        RichTextItem's superclass is CanvasItem, which provides getCanvas(), so you can get access and hide this area.

        Comment


          #5
          Originally posted by Isomorphic View Post
          Since you're hiding all of the controlGroups, you also want to hide the RichTextEditor.toolArea AutoChild.
          How do I do that?

          RichTextItem's superclass is CanvasItem, which provides getCanvas(), so you can get access and hide this area.
          Executing getCanvas() on the RichTextItem returns null even when the editor is visible.

          Regards,
          Rodolfo

          Comment


            #6
            GetCanvas() fails on RichTextItem

            Tried this code:

            ====================
            ListGridField target = new ListGridField("target", "Target", 450);
            target.setCanEdit(true);

            targetAreaItem = new RichTextItem();
            targetAreaItem.setControlGroups(new String[]{});
            targetAreaItem.addEditorEnterHandler(new EditorEnterHandler() {

            @Override
            public void onEditorEnter(EditorEnterEvent event) {
            Canvas c = targetAreaItem.getCanvas();
            if (c != null) {
            c.setAlwaysShowScrollbars(false);
            } else {
            System.err.println("Null canvas");
            }
            }
            });
            target.setEditorProperties(targetAreaItem);
            ====================

            When i click on a cell to start editing, the program prints 'Null canvas' on stderr.

            Tried debugging on Eclipse and verified that the returned canvas is null.

            So, how do I hide the controls using Java code if that's possible?

            Regards,
            Rodolfo

            Comment


              #7
              The problem is that the FormItem you're applying via setEditorProperties() is just a template, and is subject to limitations as mentioned here: http://www.smartclient.com/smartgwt/...ds.FormItem%29

              You need to rewrite your code along these lines:
              Code:
                  ListGridField target = new ListGridField("target", "Target", 450);
                  target.setCanEdit(true);
              
                  final ListGrid grid = new ListGrid();
                  grid.setFields(target);
              
                  final RichTextItem targetAreaItem = new RichTextItem();
                  targetAreaItem.setControlGroups(new String[]{});
                  targetAreaItem.addEditorEnterHandler(new com.smartgwt.client.widgets.form.fields.events.EditorEnterHandler() {
                      @Override
                      public void onEditorEnter(com.smartgwt.client.widgets.form.fields.events.EditorEnterEvent event) {
                          RichTextItem item = (RichTextItem)grid.getEditFormItem("target");
                          Canvas c = item.getCanvas();
                          if (c != null) {
                              c.setAlwaysShowScrollbars(false);
                          } else {
                              System.err.println("Null canvas");
                          }
                      }
                  });
                  target.setEditorProperties(targetAreaItem);
                      :

              Comment

              Working...
              X