Announcement

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

    6.1p Hover fires way to many requests (one request per mouse move while still over the field)

    Hi Isomorphic,

    please see this BuiltInDS based testcase (v11.1p_2018-01-11). As you can see in the video, the client fires many requests while slowly moving over the field.
    I'd expect only one request while still over the field.

    Also, from the ListGridField.setHover() docs I'd think that there must be a value-hover for email, displaying the whole field content.

    Click image for larger version

Name:	Hover issue.gif
Views:	118
Size:	226.8 KB
ID:	251194

    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.Record;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.Canvas;
    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.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("75%");
            w.setHeight("30%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle("ListGrid getCellHoverComponent called too often." + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final ListGrid hoverGrid = new ListGridHover(DataSource.get("employees"));
            hoverGrid.fetchData(new AdvancedCriteria(new Criterion("Name", OperatorId.LESS_OR_EQUAL, "B")));
            w.addItem(hoverGrid);
    
            w.show();
        }
    
        public class ListGridHover extends ListGrid {
            public ListGridHover(DataSource ds) {
                super(ds);
                setShowHover(true);
                setShowHoverComponents(true);
                setHoverWidth(500);
    
                ListGridField employeeId = new ListGridField("EmployeeId");
                employeeId.setHidden(true);
                ListGridField name = new ListGridField("Name");
                name.setShowHover(true);
                name.setShowHoverComponents(true);
                ListGridField gender = new ListGridField("Gender");
                ListGridField salary = new ListGridField("Salary");
                ListGridField email = new ListGridField("Email");
                ListGridField employeeType = new ListGridField("EmployeeType");
                ListGridField employeeStatus = new ListGridField("EmployeeStatus");
    
                setFields(employeeId, name, gender, salary, email, employeeType, employeeStatus);
            }
    
            @Override
            protected Canvas getCellHoverComponent(Record record, Integer rowNum, Integer colNum) {
                if ("Name".equals(getFieldName(colNum))) {
                    Integer reportsTo = record.getAttributeAsInt("ReportsTo");
                    ListGrid lg = new ListGrid(DataSource.get("employees"));
                    lg.fetchData(new AdvancedCriteria(new Criterion("EmployeeId", OperatorId.EQUALS, reportsTo)));
                    return lg;
                }
                return super.getCellHoverComponent(record, rowNum, colNum);
            }
        }
    }
    Best regards
    Blama

    #2
    You need to set showPrompt to false in a requestPropeties variable and use it in your lg.fetchData() call:

    Code:
        DSRequest requestPropeties = new DSRequest();
        requestPropeties.setShowPrompt(false);
        lg.fetchData(new AdvancedCriteria(new Criterion("EmployeeId", OperatorId.EQUALS, reportsTo)), null, requestPropeties);

    Comment


      #3
      Hi Isomorphic,

      I can see that this is working with your change, but having a look at the docs, I really don't understand why. Can you elaborate?

      Best regards
      Blama

      Comment


        #4
        Because having a clickmask appear means that the mouse is now over the clickmask, and not the cell, so there is a mouseOut that destroys the hover. The hover is then re-created in the exact same position once the request completes. So you are actually seeing the hover being repeatedly created and destroyed, and that's the source of the multiple requests.

        Comment

        Working...
        X