Hi Isomorphic,
please see this Testcase where the invalidateCache() request sent on button click differs from the original startup request (off by one, endRow:1000 vs 1001). This does not happen in ungrouped ListGrids.
BuiltInDS.java:
fetchData() Request:
invalidateCache() Request:
Also, as you can see, the ListGrid does not use Criteria. The docs for invalidateCache() say:
Doesn't the last sentence mean that the ListGrid should re-request data because it has no Criteria? I like the way it is now way better, but I think there is a mismatch between the docs and the current behaviour.
Best regards
Blama
please see this Testcase where the invalidateCache() request sent on button click differs from the original startup request (off by one, endRow:1000 vs 1001). This does not happen in ungrouped ListGrids.
BuiltInDS.java:
Code:
package com.smartgwt.sample.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.core.KeyIdentifier; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.SortSpecifier; import com.smartgwt.client.types.SortDirection; import com.smartgwt.client.util.PageKeyHandler; import com.smartgwt.client.util.Page; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.IButton; 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.HLayout; import com.smartgwt.client.widgets.layout.VLayout; public class BuiltInDS implements EntryPoint { private VLayout vL; private TestGrid tG; private HLayout hL; 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(); } }); vL = new VLayout(5); vL.setPadding(20); vL.setWidth100(); vL.setHeight100(); tG = new TestGrid(); hL = new HLayout(5); IButton reload = new IButton("Reload"); reload.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { vL.removeChild(tG); tG.markForRedraw(); tG = new TestGrid(); vL.addMember(tG, 0); } }); IButton getConfig = new IButton("Get ViewState"); getConfig.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { SC.say("<b>GroupState:</b><br/>" + tG.getGroupState() + "<br/><br/><b>SortState:</b><br/>" + tG.getSortState() + "<br/><br/><b>FieldState:</b><br/>" + tG.getFieldState()); } }); IButton invalidateCache = new IButton("Invalidate Cache"); invalidateCache.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { tG.invalidateCache(); } }); hL.addMembers(reload, getConfig, invalidateCache); vL.addMembers(tG, hL); vL.draw(); } private class TestGrid extends ListGrid { public TestGrid() { super(DataSource.get("animals")); setAutoFetchData(false); setCanSort(true); ListGridField commonName = new ListGridField("commonName"); ListGridField scientificName = new ListGridField("scientificName"); ListGridField lifeSpan = new ListGridField("lifeSpan"); ListGridField status = new ListGridField("status"); ListGridField diet = new ListGridField("diet"); ListGridField information = new ListGridField("information"); setGroupByField(status.getName()); setSortByGroupFirst(true); setFields(commonName, scientificName, lifeSpan, status, diet, information); setSort(new SortSpecifier[] { new SortSpecifier(lifeSpan.getName(), SortDirection.ASCENDING), new SortSpecifier(diet.getName(), SortDirection.DESCENDING) }); // fetchData(new AdvancedCriteria(new Criterion("commonName", OperatorId.NOT_NULL))); fetchData(); } } }
Code:
{ dataSource:"animals", operationType:"fetch", componentId:"isc_BuiltInDS_TestGrid_3", data:{ }, startRow:0, [B]endRow:1001[/B], sortBy:[ "status", "lifeSpan", "-diet" ], textMatchStyle:"exact", resultSet:[ResultSet ID:isc_ResultSet_3 (dataSource: animals, created by: isc_BuiltInDS_TestGrid_3)], callback:{ caller:[ResultSet ID:isc_ResultSet_3 (dataSource: animals, created by: isc_BuiltInDS_TestGrid_3)], methodName:"fetchRemoteDataReply" }, willHandleError:true, showPrompt:true, prompt:"Finding Records that match your criteria...", oldValues:{ }, requestId:"animals$6276", internalClientContext:{ requestIndex:1 }, fallbackToEval:false, lastClientEventThreadCode:"MUP9", bypassCache:true }
Code:
{ dataSource:"animals", operationType:"fetch", componentId:"isc_BuiltInDS_TestGrid_3", data:{ }, startRow:0, [B]endRow:1000[/B], sortBy:[ "status", "lifeSpan", "-diet" ], textMatchStyle:"exact", resultSet:[ResultSet ID:isc_ResultSet_3 (dataSource: animals, created by: isc_BuiltInDS_TestGrid_3)], callback:{ caller:[ResultSet ID:isc_ResultSet_3 (dataSource: animals, created by: isc_BuiltInDS_TestGrid_3)], methodName:"fetchRemoteDataReply" }, willHandleError:true, showPrompt:true, prompt:"Finding Records that match your criteria...", oldValues:{ }, requestId:"animals$6277", internalClientContext:{ requestIndex:2 }, fallbackToEval:false, lastClientEventThreadCode:"TMR0", bypassCache:true }
Originally posted by docs
Best regards
Blama
Comment