Announcement

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

    5.1p/6.1p: Fetch to scolling ListGrid has strange row range

    Hi Isomorphic,

    please see this BuiltInDS-based testcase (FF26 Dev mode using v11.1p_2017-11-16). Please also use Dev Mode as the sample needs to run be a bit slow.
    It seems that fetch to a scrolling ListGrid issues two fetches - one as expected for the rows starting from 0. But this is only the 2nd fetch. Before it also loads data for the old row range.

    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.DSRequest;
    import com.smartgwt.client.data.DSResponse;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.ResponseTransformer;
    import com.smartgwt.client.data.SortSpecifier;
    import com.smartgwt.client.types.DSOperationType;
    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.Label;
    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.events.DoubleClickEvent;
    import com.smartgwt.client.widgets.events.DoubleClickHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
    import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
    import com.smartgwt.client.widgets.layout.HLayout;
    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("Fetch to scolling ListGrid has strange row range" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final HLayout hl = new HLayout();
    
            final Label serverCountLabel = new Label("");
            serverCountLabel.setHeight100();
            serverCountLabel.setWidth(200);
            serverCountLabel.addDoubleClickHandler(new DoubleClickHandler() {
                @Override
                public void onDoubleClick(DoubleClickEvent event) {
                    serverCountLabel.setContents("");
                }
            });
            final ListGrid supplyItemParentLG = new SupplyItemListGrid(DataSource.get("supplyItem"), false);
    
            DataSource supplyItemChildDS = DataSource.get("supplyItem", null, new ResponseTransformer() {
                protected void transformResponse(DSResponse response, DSRequest request, Object data) {
                    if (request.getOperationType() == DSOperationType.FETCH) {
                        int startRow = response.getStartRow();
                        int endRow = response.getEndRow();
                        String criteria = request.getCriteria().asAdvancedCriteria().toJSON();
                        serverCountLabel.setContents(serverCountLabel.getContents() + criteria + "(" + startRow + "-" + endRow + ")<br />");
                    }
                    defaultTransformResponse(response, request, data);
                }
            });
            final ListGrid supplyItemChildLG = new SupplyItemListGrid(supplyItemChildDS, true);
    
            supplyItemParentLG.addRecordClickHandler(new RecordClickHandler() {
                @Override
                public void onRecordClick(RecordClickEvent event) {
                    String itemName = event.getRecord().getAttribute("itemName");
                    supplyItemChildLG.fetchData(new AdvancedCriteria("itemName", OperatorId.GREATER_THAN, itemName));
                }
            });
    
            hl.setMembers(supplyItemParentLG, supplyItemChildLG, serverCountLabel);
            w.addItem(hl);
            w.show();
    
            supplyItemParentLG.fetchData(new AdvancedCriteria("itemName", OperatorId.GREATER_THAN, "S"));
        }
    
        private class SupplyItemListGrid extends ListGrid {
            public SupplyItemListGrid(DataSource ds, boolean withSKU) {
                super(ds);
                setAutoFetchData(false);
                setCanEdit(false);
                setCanGroupBy(false);
                setCanSort(false);
                setDataPageSize(100);
    
                ListGridField itemID = new ListGridField("itemID");
                itemID.setCanHide(false);
                itemID.setHidden(true);
                ListGridField itemName = new ListGridField("itemName");
                ListGridField sku = new ListGridField("SKU");
                setInitialSort(new SortSpecifier("itemName", SortDirection.ASCENDING));
    
                if (withSKU)
                    setFields(itemID, itemName, sku);
                else
                    setFields(itemID, itemName);
            }
        }
    }
    Preparation: Click 1st item on the left to load childLG, clear log.
    Then scroll childLG via Pg-Dn-key and at the same time, click another item in the parentLG.
    Click image for larger version

Name:	Scrolling ListGrid.gif
Views:	115
Size:	161.2 KB
ID:	250593

    Also, could you explain why the ResponseTransformer is also run for the fetch to the parent ListGrid on start? This does not seem right.

    Best regards
    Blama

    #2
    It's not clear what your expecting here. By clicking the parent you create a fetch, that fetch won't be aborted due to the second fetch.

    Also, when you install a ResponseTransformer, it runs for all operations on that DataSource.

    Comment


      #3
      Hi Isomorphic,

      it's the click that *causes* the two fetches. Please see the criteria in the right debug output to see that both fetches are click related and none is scroll related.
      I'd expect only the 0-75 fetch in the video, not the other one.

      Thanks for the information on the ResponseTransformer. This basically means that DataSource.get() returns a singleton, right? If it is that way, it would be good if the docs said so.

      Best regards
      Blama

      Comment


        #4
        Hi Isomorphic,

        actually it is even more simple. Fetching in a scrolled grid (no need that is is currently scrolling) results in a new request with the old scroll position and then with the expected one with start at row 0.

        Best regards
        Blama

        Comment


          #5
          Hi Isomorphic,

          could you reproduce this one?

          Best regards
          Blama

          Comment


            #6
            Yes, this should be fixed in SGWT 5.1/SC 10.1 and newer releases for builds starting 2017-12-02, though the thread didn't get updated.

            Comment


              #7
              Hi Isomorphic,

              thanks, I just retested. It's fixed for me using v10.1p_2017-12-21 and v11.1p_2017-12-29.

              Thank you & Best regards
              Blama

              Comment


                #8
                Hi Isomorphic,

                as it turns out, this is fixed for the testcase, but not my application. In order to make the testcase like the application and cause the issue, you only need add setShowRecordComponents(true) to the SupplyItemListGrid-class in the sample.
                Then the ListGrid does again issue two fetches and additionally does not scroll to top. Tested with v11.1p_2018-01-11.

                Click image for larger version

Name:	Rowrange.gif
Views:	79
Size:	246.0 KB
ID:	251236

                Best regards
                Blama

                Comment


                  #9
                  This should be fixed back to SGWT 5.1/SC 10.1 in the nightly builds dated 2017-01-17 and beyond.

                  Comment


                    #10
                    Hi Isomorphic,

                    I can see that this is fixed in v11.1p_2018-01-23.

                    Thank you & Best regards
                    Blama

                    Comment

                    Working...
                    X