Announcement

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

  • ListGrid.setMinFieldWidth(50) and removeField-width

    Hi Isomorphic,

    using 6.1d, is there a way using ListGrid.setMinFieldWidth(50) and at the same time keeping generated fields like the removeField for setCanRemoveRecords(true) or the rowNumberField for setShowRowNumbers(true) at their normal sizes?

    This does not work for me, the width is 50 anyway.
    Code:
            ListGrid lg = new ListGrid() {
                {
                    setMinFieldWidth(50);
                    setRemoveFieldProperties(new ListGridField() {
                        {
                            setWidth(24);
                        }
                    });
                }
            };
            ListGrid.setDefaultProperties(lg);
    Perhaps the method that checks the minFieldWidth should exclude those two fields?

    Thank you & Best regards
    Blama

  • #2
    Are you seeing a problem with the initial draw of the grid, or trying to use autofit? We're not seeing any issue like what you claim unless autofit is used.

    Can you provide the complete sample code?

    Comment


    • #3
      Hi Isomorphic,

      yes, see this BuiltInDS based sample (SNAPSHOT_v11.1d_2017-04-14):
      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.data.SortSpecifier;
      import com.smartgwt.client.types.Autofit;
      import com.smartgwt.client.types.OperatorId;
      import com.smartgwt.client.types.SortDirection;
      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.fields.ComboBoxItem;
      import com.smartgwt.client.widgets.grid.ListGrid;
      import com.smartgwt.client.widgets.grid.ListGridField;
      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();
                  }
              });
      
              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.setHeight("95%");
              w.setMembersMargin(0);
              w.setModalMaskOpacity(70);
              w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
              w.setTitle("TITLE" + w.getTitle());
              w.setShowMinimizeButton(false);
              w.setIsModal(true);
              w.setShowModalMask(true);
              w.centerInPage();
              w.setCanDragResize(true);
      
              final ListGrid employeesGrid = new ListGrid();
      
              employeesGrid.setHeight100();
              employeesGrid.setAutoFetchData(false);
              employeesGrid.setDataSource(DataSource.get("employees"));
              employeesGrid.setCanGroupBy(false);
              employeesGrid.setShowRecordComponents(false);
              employeesGrid.setShowRecordComponentsByCell(false);
              employeesGrid.setAutoFitExpandField("MaritalStatus");
              employeesGrid.setMinFieldWidth(100);
              employeesGrid.setCanRemoveRecords(true);
              employeesGrid.setShowRowNumbers(true);
      
              ListGridField employeeId = new ListGridField("EmployeeId");
              ListGridField name = new ListGridField("Name");
              ListGridField gender = new ListGridField("Gender");
              ListGridField reportsTo = new ListGridFieldReportsTo("ReportsTo");
              ListGridField job = new ListGridField("Job");
              ListGridField email = new ListGridField("Email");
              ListGridField employeeType = new ListGridField("EmployeeType");
              ListGridField employeeStatus = new ListGridField("EmployeeStatus");
              ListGridField salary = new ListGridField("Salary");
              ListGridField orgUnit = new ListGridField("OrgUnit");
              ListGridField maritalStatus = new ListGridField("MaritalStatus");
      
              employeesGrid.setFields(employeeId, name, gender, reportsTo, job, email, employeeType, employeeStatus, salary, orgUnit, maritalStatus);
              employeesGrid.setSort(new SortSpecifier[] { new SortSpecifier(name.getName(), SortDirection.ASCENDING) });
              employeesGrid.fetchData(new AdvancedCriteria(new Criterion(name.getName(), OperatorId.STARTS_WITH, "A")));
              w.addItem(employeesGrid);
              w.show();
          }
      
          private class ListGridFieldReportsTo extends ListGridField {
              public ListGridFieldReportsTo(String name) {
                  super(name);
                  ComboBoxItem managerCBI = new ComboBoxItem();
                  managerCBI.setOptionDataSource(DataSource.get("employees"));
                  managerCBI.setOptionOperationId("foobar");
                  managerCBI.setValueField(DataSource.get("employees").getPrimaryKeyFieldName());
                  managerCBI.setDisplayField("Name");
                  managerCBI.setPickListSort(new SortSpecifier[] { new SortSpecifier("EmployeeId", SortDirection.ASCENDING),
                          new SortSpecifier("Name", SortDirection.ASCENDING) });
                  ListGridField managerCBI_empIdLGF = new ListGridField("EmployeeId");
                  ListGridField managerCBI_nameLGF = new ListGridField("Name");
                  managerCBI.setPickListFields(managerCBI_empIdLGF, managerCBI_nameLGF);
                  managerCBI.setPickListHeaderHeight(0);
                  setEditorProperties(managerCBI);
              }
          }
      }
      There are a few things to notice:
      • The removeRecord field is too wide as described in the original post.
      • Starting from employeesGrid.setMinFieldWidth(25) there is always a horizontal scrollbar, as (my guess) the ListGrid wants to leave less space for the removeField, sizes the other fields accordingly and then has to introduce the scrollbar in order to add the wider-than-expected removeField.
      • Calling autoAitAllFields from the menu assigns the extra space to the removeField, not the setAutoFitExpandField("MaritalStatus"). This goes away if you comment out setShowRowNumbers(true).
      • The removeField is resizeable by default, unlike the rowNumberField.
      Best regards
      Blama

      Comment


      • #4
        Your issue specifically with the "remove record" field was caused by it being internally configured to autofit, which made it always subject to ListGrid.minFieldWidth, even if it had a fixed width already set. This has been fixed back to SGWT 6.0p and will be in the nightly builds dated 2017-04-20 and beyond.

        The other behavior you describe, such as the minFieldWidth being applied to all fields during a manual autofit, or the ListGrid overflowing horizontally creating a scrollbar during a manual autofit, are both by design, and have been in place for many releases.

        Comment

        Working...
        X