Announcement

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

    ComboBoxItem.setPickListSort() does no longer sort the PickList contents

    Hi Isomorphic,

    using latest 5.1p (v10.1p_2017-04-04) I noticed that setPickListSort() called before creation of the ComboBoxItem does not sort the contents, only setInitialSort() does.
    I'm pretty sure this worked before. I do not know when this behavior changed.

    Please see this testcase:

    BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.SortSpecifier;
    import com.smartgwt.client.types.FetchMode;
    import com.smartgwt.client.types.SortDirection;
    import com.smartgwt.client.types.TextMatchStyle;
    import com.smartgwt.client.types.VerticalAlignment;
    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.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.DynamicForm;
    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.HLayout;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        private VLayout mainLayout;
    
        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();
    
            HLayout buttonsLayout = new HLayout();
            buttonsLayout.setHeight(30);
            IButton recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate();
                }
            });
            buttonsLayout.addMember(recreateBtn);
    
            mainLayout.addMember(buttonsLayout);
            mainLayout.setAlign(VerticalAlignment.TOP);
            recreate();
            mainLayout.draw();
        }
    
        private void recreate() {
            if (mainLayout.getMembersLength() > 1) {
                mainLayout.removeMember(mainLayout.getMember(1));
            }
            mainLayout.addMember(getComponent(), 1);
        }
    
        private DynamicForm getComponent() {
            DynamicForm df = new DynamicForm();
            MyComboBoxItem mcbi1 = new MyComboBoxItem(false);
            mcbi1.setTitle("Unsorted (wrong)");
            MyComboBoxItem mcbi2 = new MyComboBoxItem(true);
            mcbi2.setTitle("Sorted (correct)");
            df.setFields(mcbi1, mcbi2);
            return df;
        }
    
        private class MyComboBoxItem extends ComboBoxItem {
            public MyComboBoxItem(boolean useInitial) {
                setOptionDataSource(DataSource.get("employees"));
                setValueField(DataSource.get("employees").getPrimaryKeyFieldName());
                setAllowEmptyValue(true);
    
                ListGridField employeeId = new ListGridField("EmployeeId");
                employeeId.setHidden(true);
                ListGridField name = new ListGridField("Name");
                ListGridField gender = new ListGridField("Gender");
                ListGridField job = new ListGridField("Job");
    
                setPickListFields(employeeId, name, gender, job);
    
                // See here
                if (useInitial)
                    setInitialSort(new SortSpecifier[] { new SortSpecifier(gender.getName(), SortDirection.ASCENDING),
                            new SortSpecifier(name.getName(), SortDirection.ASCENDING) });
                else
                    setPickListSort(new SortSpecifier[] { new SortSpecifier(gender.getName(), SortDirection.ASCENDING),
                            new SortSpecifier(name.getName(), SortDirection.ASCENDING) });
    
                setPickListHeaderHeight(0);
                setPickListWidth(350);
    
                setTextMatchStyle(TextMatchStyle.SUBSTRING);
                setBrowserSpellCheck(false);
    
                setAddUnknownValues(false);
                setPickListProperties(new ListGrid() {
                    {
                        setDataFetchMode(FetchMode.BASIC);
                    }
                });
            }
        }
    }
    This is an important one for me.

    Best regards
    Blama

    #2
    Hi Isomorphic,

    can you reproduce this one?

    Best regards
    Blama

    Comment


      #3
      We neglected to update this tread, our apologies, but we made a change on April 6 that ought to address this issue - setPickLIstSort() should now be applying it's parameter as initialSort when called before draw().

      Let us know if you don't see that fix.

      Comment


        #4
        Hi Isomorphic,

        I did not retest with 5.1p, but using SNAPSHOT_v11.1d_2017-04-13 and the same testcase, the issue still exists.

        Best regards
        Blama

        Comment


          #5
          Ok, we'll take another look and update when we have more information.

          Comment


            #6
            setPickListSort() before draw correctly updates item.pickListPropeties.initialSort - however, your subsequent call to setPickListProperties() is clobbering the initialSort - just move that call so it happens before setPickListSort().

            Comment


              #7
              Hi Isomorphic,

              now using SNAPSHOT_v11.1d_2017-04-14 and also changed the order of the statements and it's working as it should. Thanks a lot.

              Best regards
              Blama

              Comment

              Working...
              X