Announcement

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

    Problem with missing filter text after filtering field with displayField and setFilterOperator

    Hi Isomorphic,

    please see this testcase (v11.1p_2017-09-11). It seems that for fields with displayField and the filter string is not displayed after filtering, even though the does filter.
    Also, the request after a invalidateCache() does include the expected criteria (see the "Reload" button).
    The issue seems to be related to the line reportsTo.setFilterOperator(OperatorId.ICONTAINS) in the code.

    Click image for larger version

Name:	Filter-text-disappears.gif
Views:	142
Size:	76.0 KB
ID:	249129

    BuiltInDS.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.data.SortSpecifier;
    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.TextItem;
    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("ListGrid has problem with filtering for fields with displayField" + 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"));
            employeesGrid.setShowFilterEditor(true);
    
            ListGridField employeeId = new ListGridField("EmployeeId");
            employeeId.setCanEdit(false);
    
            ListGridField name = new ListGridField("Name");
            name.setCanEdit(false);
    
            ListGridField gender = new ListGridField("Gender");
    
            ListGridField reportsTo = new ListGridField("ReportsTo");
    [B]        // Without, it is displaying, but using equals criteria
            reportsTo.setFilterOperator(OperatorId.ICONTAINS);[/B]
            reportsTo.setFilterEditorProperties(new TextItem());
    
            ListGridField job = new ListGridField("Job");
    
            employeesGrid.setFields(employeeId, name, gender, reportsTo, job);
            employeesGrid.setSort(new SortSpecifier[] { new SortSpecifier(reportsTo.getName(), SortDirection.ASCENDING) });
            employeesGrid.fetchData(new AdvancedCriteria(new Criterion(name.getName(), OperatorId.STARTS_WITH, "A")));
            w.addItem(employeesGrid);
    
            IButton reloadBtn = new IButton("Reload", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    employeesGrid.invalidateCache();
                }
            });
            w.addItem(reloadBtn);
            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" useAnsiJoins="true">
        <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" displayField="ReportsToName" />
            <field name="ReportsToName"   includeFrom="employees.Name" title="Manager name" />
            <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="MaritalStatus"   title="Marital Status"  type="text"     length="10">
                <valueMap>
                    <value>married</value>
                    <value>single</value>
                </valueMap>
            </field>
        </fields>
    </DataSource>
    Best regards
    Blama

    #2
    The underlying field is a number, and an FK, so equals is the default operator - when you force iContains, the return criteria is being considered non-editable after the round-trip, because number fields don't support iContains.

    We'll take a look and get back to you.
    Last edited by Isomorphic; 13 Sep 2017, 05:55.

    Comment


      #3
      This has been fixed for builds dated September 19 and later - whether an operator is considered valid (and criteria can be edited after a round-trip) is now based on the criteriaField, which is what you're entering filter values for, rather than the actual field.

      Comment


        #4
        Hi Isomorphic,

        I can see that it is fixed using v11.1p_2017-09-20.

        Please note that the operators offered on right click when using filterOperators also seem to differ depending on the field-type, not the criteriaField-type, as I'd expect.

        Best regards
        Blama

        Comment


          #5
          This issue has also been addressed, for builds dated September 22 and later.

          Comment


            #6
            Hi Isomorphic,

            I can confirm it's fixed for me using v11.1p_2017-10-05.

            Best regards
            Blama

            Comment

            Working...
            X