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.
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.
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
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); } } }
Then scroll childLG via Pg-Dn-key and at the same time, click another item in the parentLG.
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
Comment