Announcement

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

    6.1p: LinkItems do not respect setHeight if used in a Dynamic Form with TitleOrientation.TOP

    Hi Isomorphic,

    please see this testcase (v11.1p_2017-08-15) with some LinkItem and DynamicForms design issues.
    Problems:
    • I'd expect the LinkItem to look like the TextItem when editing (Textentry box is not high enough) in DynamicForms 1+3.
    • I'd expect all titles to be on one level in DynamicForms 1+2 (the TitleOrientation.TOP ones)
    • Minor: Why is the name.setCanEdit(true) needed when there is already df.setCanEdit(true) in DynamicForms 1+3.
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.Version;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.AdvancedCriteria;
    import com.smartgwt.client.data.Criterion;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.types.TitleOrientation;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.LinkItem;
    import com.smartgwt.client.widgets.form.fields.StaticTextItem;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        private VLayout mainLayout;
        private IButton recreateBtn;
    
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            LinkItem li = new LinkItem() {
                {
                    setWidth("*");
                    setHeight(60);
                    setCanSelectText(true);
                }
            };
            LinkItem.setDefaultProperties(li);
    
            TextItem ti = new TextItem() {
                {
                    setWidth("*");
                    setHeight(60);
                    setCanSelectText(true);
                }
            };
            TextItem.setDefaultProperties(ti);
    
            LinkItem.setDefaultProperties(li);
    
            StaticTextItem sti = new StaticTextItem() {
                {
                    setWidth("*");
                    setHeight(60);
                    setCanSelectText(true);
                }
            };
            StaticTextItem.setDefaultProperties(sti);
    
            mainLayout = new VLayout(20);
            mainLayout.setWidth100();
            mainLayout.setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate();
                }
            });
            mainLayout.addMember(recreateBtn);
            recreate();
            mainLayout.draw();
        }
    
        private void recreate() {
            Window w = new Window();
            w.setWidth("95%");
            w.setCanDragResize(true);
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle("LinkItems do not respect setHeight if used in a Dynamic Form with TitleOrientation.TOP" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            {
                final DynamicForm df = new DynamicForm();
                df.setIsGroup(true);
                df.setGroupTitle("DF1");
                df.setTitleOrientation(TitleOrientation.TOP);
                df.setNumCols(3);
                df.setDataSource(DataSource.get("employees"));
                df.setCanEdit(true);
                StaticTextItem sti = new StaticTextItem("sti", "Dummyitem");
                sti.setDefaultValue("LinkItems do not respect setHeight if used in a Dynamic Form with TitleOrientation.TOP");
                TextItem employeeId = new TextItem("EmployeeId");
                LinkItem name = new LinkItem("Name");
                // Why this is needed?
                name.setCanEdit(true);
    
                df.setFields(employeeId, name, sti);
                df.fetchData(new AdvancedCriteria(new Criterion(employeeId.getName(), OperatorId.EQUALS, 4)));
                w.addItem(df);
            }
    
            {
                final DynamicForm df = new DynamicForm();
                df.setIsGroup(true);
                df.setGroupTitle("DF2");
                df.setTitleOrientation(TitleOrientation.TOP);
                df.setNumCols(2);
                df.setDataSource(DataSource.get("employees"));
                df.setCanEdit(false);
                TextItem employeeId = new TextItem("EmployeeId");
                LinkItem name = new LinkItem("Name");
    
                df.setFields(employeeId, name);
                df.fetchData(new AdvancedCriteria(new Criterion(employeeId.getName(), OperatorId.EQUALS, 4)));
                w.addItem(df);
            }
    
            {
                final DynamicForm df = new DynamicForm();
                df.setIsGroup(true);
                df.setGroupTitle("DF3");
                df.setDataSource(DataSource.get("employees"));
                df.setCanEdit(true);
                TextItem employeeId = new TextItem("EmployeeId");
                LinkItem name = new LinkItem("Name");
                // Why this is needed?
                name.setCanEdit(true);
    
                df.setFields(employeeId, name);
                df.fetchData(new AdvancedCriteria(new Criterion(employeeId.getName(), OperatorId.EQUALS, 4)));
                w.addItem(df);
            }
    
            {
                final DynamicForm df = new DynamicForm();
                df.setIsGroup(true);
                df.setGroupTitle("DF4");
                df.setDataSource(DataSource.get("employees"));
                df.setCanEdit(false);
                TextItem employeeId = new TextItem("EmployeeId");
                LinkItem name = new LinkItem("Name");
    
                df.setFields(employeeId, name);
                df.fetchData(new AdvancedCriteria(new Criterion(employeeId.getName(), OperatorId.EQUALS, 4)));
                w.addItem(df);
            }
            w.show();
        }
    }
    Click image for larger version

Name:	LinkItem-Height.PNG
Views:	64
Size:	19.7 KB
ID:	248453


    Best regards
    Blama

    #2
    Hi Isomorphic,

    I remembered asking a similar question before and found it now. setApplyHeightToTextBox() solves issues 1+2 when used for LinkItem and StaticTextItem.
    Minor issue 3 is still open.

    Best regards
    Blama

    Comment


      #3
      The default editing mode for a LinkItem is non-editable, by design. canEdit on a FormItem overrides the setting for the overall form, also by design.

      Comment

      Working...
      X