Hi Isomorphic,
creating this testcase I noticed a strange difference between using fetchData(criterion) and setInitialCriteria(criterion) (also using v11.1p_2017-12-05).
Please see how the criteria look in the fetchData()-case:
and compare it to the setInitialCriteria()-case:
I'd expect both to be the same and assume that the outer-AND AdvancedCriterion is an advantage if doing further filtering in the GUI, as long as you can't tell for any two resultSets if one is a subset of the other and therefore you can do client side filtering.
BuiltInDS.java:
Best regards
Blama
creating this testcase I noticed a strange difference between using fetchData(criterion) and setInitialCriteria(criterion) (also using v11.1p_2017-12-05).
Please see how the criteria look in the fetchData()-case:
Code:
data:{ fieldName:"unitCost", operator:"equals", value:0.41 },
Code:
data:{ operator:"and", criteria:[ { fieldName:"unitCost", operator:"equals", value:0.41 } ] },
BuiltInDS.java:
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.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.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("50%"); w.setHeight("50%"); w.setMembersMargin(0); w.setModalMaskOpacity(70); w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")"); w.setTitle("ListGrid fetches differ when using fetchData() or setInitialCriteria() with Criterion-type parameter" + w.getTitle()); w.setShowMinimizeButton(false); w.setIsModal(true); w.setShowModalMask(true); w.centerInPage(); final ListGrid supplyItemLG = new SupplyItemListGrid(); final ListGrid supplyItem2LG = new SupplyItemListGrid(); // supplyItem2LG.setInitialCriteria(new AdvancedCriteria("unitCost", OperatorId.EQUALS, 0.41F)); supplyItem2LG.setInitialCriteria(new Criterion("unitCost", OperatorId.EQUALS, 0.41F)); supplyItem2LG.setAutoFetchData(true); w.addItem(supplyItemLG); w.addItem(supplyItem2LG); w.show(); // supplyItemLG.fetchData(new AdvancedCriteria("unitCost", OperatorId.EQUALS, 0.41F)); supplyItemLG.fetchData(new Criterion("unitCost", OperatorId.EQUALS, 0.41F)); } private class SupplyItemListGrid extends ListGrid { public SupplyItemListGrid() { super(DataSource.get("supplyItem")); setAutoFetchData(false); setCanEdit(false); setCanGroupBy(false); setCanSort(false); setShowFilterEditor(true); setAllowFilterOperators(true); ListGridField itemID = new ListGridField("itemID"); itemID.setCanHide(false); itemID.setHidden(true); ListGridField itemName = new ListGridField("itemName"); ListGridField sku = new ListGridField("SKU"); ListGridField description = new ListGridField("description"); ListGridField category = new ListGridField("category"); ListGridField units = new ListGridField("units"); ListGridField unitCost = new ListGridField("unitCost"); ListGridField inStock = new ListGridField("inStock"); ListGridField nextShipment = new ListGridField("nextShipment"); setInitialSort(new SortSpecifier("itemName", SortDirection.ASCENDING)); setFields(itemID, itemName, sku, description, category, units, unitCost, inStock, nextShipment); } } }
Blama