Announcement

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

    ComboBoxItem setPickListCriteria not working in recent 5.1p

    Hi Isomorphic,

    using current 5.1p (v10.1p_2017-08-20), ComboBoxItem setPickListCriteria() seems to be not working. I'm not sure if this is a regression, but can remember posting a similar thing. It might be this one or even more related.
    The issue now has been happening for me for a long time, so if it's a regression, it's not a recent one.
    Please see this testcase:

    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.FetchMode;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.types.SortDirection;
    import com.smartgwt.client.types.TextMatchStyle;
    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.ComboBoxItem;
    import com.smartgwt.client.widgets.form.fields.FormItem;
    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("ComboBoxItem SortSpecifiers not working" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final DynamicForm employeesDF = new DynamicForm();
            employeesDF.setDataSource(DataSource.get("employees"));
            FormItem employeeIdLGF = new FormItem("EmployeeId");
            FormItem nameLGF = new FormItem("Name");
            FormItem genderLGF = new FormItem("Gender");
            MyComboBoxItem mcbi = new MyComboBoxItem("ReportsTo");
    
            employeesDF.setFields(employeeIdLGF, nameLGF, genderLGF, mcbi);
            employeesDF.fetchData(new AdvancedCriteria(new Criterion(employeeIdLGF.getName(), OperatorId.EQUALS, 182)));
            w.addItem(employeesDF);
            w.show();
        }
    
        private class MyComboBoxItem extends ComboBoxItem {
            public MyComboBoxItem(String name) {
                super(name);
                setOptionDataSource(DataSource.get("employees"));
                setPickListCriteria(new AdvancedCriteria(new Criterion("Name", OperatorId.GREATER_OR_EQUAL, "C")));
                setValueField(DataSource.get("employees").getPrimaryKeyFieldName());
                setDisplayField("Name");
                setAllowEmptyValue(true);
    
                ListGridField employeeIdLGF = new ListGridField("EmployeeId");
                ListGridField nameLGF = new ListGridField("Name");
                ListGridField genderLGF = new ListGridField("Gender");
    
                setPickListFields(employeeIdLGF, nameLGF, genderLGF); // setPickListFields() / setPickListSort()-order does not matter
                setPickListSort(new SortSpecifier[] { new SortSpecifier("Gender", SortDirection.ASCENDING),
                        new SortSpecifier("Name", SortDirection.ASCENDING), new SortSpecifier("EmployeeId", SortDirection.ASCENDING) });
                // setSortField("Name"); // Working as expected
    
                setPickListHeaderHeight(0);
                setPickListWidth(350);
    
                setTextMatchStyle(TextMatchStyle.SUBSTRING);
                setBrowserSpellCheck(false);
    
                setAddUnknownValues(false);
                setPickListProperties(new ListGrid() {
                    {
                        setDataFetchMode(FetchMode.BASIC);
                    }
                });
            }
        }
    }
    Click image for larger version

Name:	ComboBoxItem-sort.PNG
Views:	68
Size:	6.3 KB
ID:	248667

    Best regards
    Blama

    #2
    Your call to setPickListSort() is working as expected - in this case, pre-draw, it updates pickListProperties.initalSort.

    So, your subsequent call so setPickListProperties() clobbers the effect of setPickListSort().

    Just set up sorting after calling setPickListProperties().

    Comment

    Working...
    X