Announcement

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

    SelectItem behavior for setAllowEmptyValue(true) and setMultiple(true) changed

    Hi Isomorphic,

    please see this testcase in v10.1p_2016-05-25 which directly resembles my application setting.
    It may not be useful to have setAllowEmptyValue(true) + setMultiple(true) together, but this worked before (Apr 27th build).

    As you can see, the Multiselects show both an empty entry at the very top.
    If you just hit load you'll get (messed up) criteria where I'd expect to get null-criteria. The messed up is not a problem here, but that criteria are generated *at all* is the problem.
    The empty entry is there if you use a valueMap and also if you use databound criteria (I only have the databound in my application).
    This is all healed by removing setAllowEmptyValue(true), but this used to work.

    Testcase BuildInDS.java:
    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.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.FormItemCriterionGetter;
    import com.smartgwt.client.widgets.form.fields.ButtonItem;
    import com.smartgwt.client.widgets.form.fields.FormItem;
    import com.smartgwt.client.widgets.form.fields.SelectItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    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();
    
            final ListGrid employeesGrid = new ListGrid();
            employeesGrid.setHeight100();
            employeesGrid.setAutoFetchData(false);
            employeesGrid.setDataSource(DataSource.get("employees"));
    
            final DynamicForm df = new DynamicForm();
            SelectItem si = new SelectItem("GenderHC", "Select Gender (hardcoded)");
            si.setAllowEmptyValue(true);
            si.setMultiple(true);
            si.setValueMap("male", "female");
    
            SelectItem si2 = new SelectItem("Gender", "Select Gender (databound)");
            si2.setAllowEmptyValue(true);
            si2.setMultiple(true);
            si2.setOptionDataSource(DataSource.get("employees"));
            si2.setOptionOperationId("fetchGenders");
    
            si2.setCriterionGetter(new FormItemCriterionGetter() {
                @Override
                public Criterion getCriterion(DynamicForm form, FormItem item, TextMatchStyle textMatchStyle) {
                    return this.getCriterion(form, item);
                }
    
                @Override
                public Criterion getCriterion(DynamicForm form, FormItem item) {
                    SelectItem si = (SelectItem) item;
                    if (si.getSelectedRecords() != null && si.getSelectedRecords().length > 0) {
                        AdvancedCriteria finalOrCrit = new AdvancedCriteria(OperatorId.OR);
                        for (int i = 0; i < si.getSelectedRecords().length; i++) {
                            String productId = si.getSelectedRecords()[i].getAttributeAsString("Gender");
                            productId = ", " + productId + ",";
                            finalOrCrit.appendToCriterionList(new Criterion("Gender", OperatorId.CONTAINS, productId));
                        }
                        return finalOrCrit;
                    } else
                        return null;
                }
            });
    
            ButtonItem bi = new ButtonItem("LOAD", "Load Data");
            bi.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
                @Override
                public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
                    employeesGrid.fetchData(df.getValuesAsAdvancedCriteria());
                }
            });
            df.setFields(si, si2, bi);
    
            w.addItem(df);
            w.addItem(employeesGrid);
            w.show();
        }
    }
    employees.ds.xml:
    Code:
    <DataSource
        ID="employees"
        serverType="sql"
        tableName="employeeTable"
        recordName="employee"
        testFileName="/examples/shared/ds/test_data/employees.data.xml"
        titleField="Name"
    >
        <fields>
            <field name="userOrder"       title="userOrder"       type="integer"  canEdit="false"    hidden="true"/>
            <field name="Name"            title="Name"            type="text"     length="128"/>
            <field name="EmployeeId"      title="Employee ID"     type="integer"  primaryKey="true"  required="true"/>
            <field name="ReportsTo"       title="Manager"         type="integer"  required="true" 
                   foreignKey="employees.EmployeeId"  rootValue="1" detail="true"/>
            <field name="Job"             title="Title"           type="text"     length="128"/> 
            <field name="Email"           title="Email"           type="text"     length="128"/>
            <field name="EmployeeType"    title="Employee Type"   type="text"     length="40"/>
            <field name="EmployeeStatus"  title="Status"          type="text"     length="40"/>
            <field name="Salary"          title="Salary"          type="float"/>
            <field name="OrgUnit"         title="Org Unit"        type="text"     length="128"/>
            <field name="Gender"          title="Gender"          type="text"     length="7">
                <valueMap>
                    <value>male</value>
                    <value>female</value>
                </valueMap>
            </field>
            <field name="GenderHC"        title="GenderHC"        type="text"     length="7" customSelectExpression="Gender" />
            <field name="MaritalStatus"   title="Marital Status"  type="text"     length="10">
                <valueMap>
                    <value>married</value>
                    <value>single</value>
                </valueMap>
            </field>
        </fields>
        <operationBindings>
            <operationBinding operationType="fetch" operationId="fetchGenders" outputs="Gender">
                <groupBy>Gender</groupBy>
            </operationBinding>
        </operationBindings>
    </DataSource>
    Best regards
    Blama

    #2
    We've made a change to address this issue. Please try the next nightly build, dated June 2.

    Regards
    Isomorphic Software

    Comment


      #3
      Hi Isomorphic,

      I can confirm this is fixed using v10.1p_2016-06-03.

      Best regards
      Blama

      Comment

      Working...
      X