Announcement

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

    11.1p Client side ListGrid filtering issues unexpected requests

    Hi Isomorphic,

    please see this video (v11.1p_2018-02-16) where you can see many unexpected requests when filtering for the 1st time - subsequent filtering seems to work w/o server contact.
    As the loaded ListGrid has already all records of the ResultSet, I'd expect no further requests.

    Click image for larger version  Name:	Client side filtering issues unexpected requests.gif Views:	1 Size:	380.2 KB ID:	251837

    Also, I'd expect to see column ReportsTo as I'm setting employeesGrid.setShowDetailFields(true).

    This is the BuiltInDS based testcase (BuiltInDS.java file only):
    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.SelectItem;
    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(400);
            w.setHeight(350);
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle("Client side filtering issues unexpected requests" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final ListGrid employeesGrid = new ListGrid(DataSource.get("employees"));
            employeesGrid.setHeight100();
            employeesGrid.setAutoFetchData(false);
            employeesGrid.setCanEdit(true);
            employeesGrid.setShowFilterEditor(true);
            employeesGrid.setFilterOnKeypress(true);
    [B]        employeesGrid.setShowDetailFields(true);[/B]
    
            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");
    
            employeesGrid.setFields(employeeId, name, gender, reportsTo, job);
            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);
                SelectItem managerCBI = new SelectItem();
                managerCBI.setOptionDataSource(DataSource.get("employees"));
                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);
                // setMultiple(true);
                setFilterEditorProperties(managerCBI);
            }
        }
    }
    Best regards
    Blama
    Last edited by Blama; 17 Feb 2018, 14:37.

    #2
    The initial fetchData() call in the sample configures the ResultSet with textMatchStyle:”exact” because the request doesn’t have an explicit value. Changing the grid filter results in a filterData() call which sets the textMatchStyle:”substring” (see filterData() docs for details). If the textMatchStyle had not changed the criteria would be more restrictive.

    Ways to get the desired behavior:
    1. call filterData() instead of fetchData()
    2. set textMatchStyle to "substring" in the fetchData() requestProperties
    3. enable autoFetchData:true, set initialCriteria and autoFetchTextMatchStyle:"substring"

    Explicitly setting the field's filter operator may also be helpful.

    As for the showDetailFields option, please check the docs. That attribute only applies if fields are not configured explicitly with setFields().

    Comment

    Working...
    X