Hi Isomorphic,
please see this v10.1p_2015-12-18/PowerEdition BuiltInDS-based testcase:
BuiltInDS.java:
supplyItem.ds.xml:
So the error is only occuring in a grouped ListGrid with a field, where the displayField is only set in .ds.xml.
I'm not sure if this is also related to the type of the field/displayField.
Tested in GC47 Compiled and FF26 Dev Mode.
Best regards
Blama
please see this v10.1p_2015-12-18/PowerEdition BuiltInDS-based testcase:
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.AdvancedCriteria; import com.smartgwt.client.data.Criterion; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.SortSpecifier; import com.smartgwt.client.types.GroupStartOpen; 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("95%"); w.setHeight("95%"); w.setMembersMargin(0); w.setModalMaskOpacity(70); w.setTitle("Grouped ListGrid: Sort-By field not used in DSRequest when not setting displayField again in Java."); w.setShowMinimizeButton(false); w.setIsModal(true); w.setShowModalMask(true); w.centerInPage(); final ListGrid supplyItem = new ListGrid(); supplyItem.setHeight100(); supplyItem.setAutoFetchData(false); supplyItem.setSortByGroupFirst(true); supplyItem.setDataSource(DataSource.get("supplyItem")); supplyItem.setGroupStartOpen(GroupStartOpen.ALL); supplyItem.setGroupSortDirection(SortDirection.ASCENDING); supplyItem.setGroupByField("category"); ListGridField category = new ListGridField("category"); ListGridField itemID = new ListGridField("itemID"); /* With this line, the RPC Request contains "itemName" as 2nd sortfield. Without this line, the RPC Request contains neither "itemName" nor "itemID" as 2nd sortfield. */ // itemID.setDisplayField("itemName"); ListGridField SKU = new ListGridField("SKU"); ListGridField description = new ListGridField("description"); supplyItem.setFields(category, itemID, SKU, description); // No difference if setSortState or setSort is used. // supplyItem // .setSortState("({fieldName:\"itemID\",sortDir:\"ascending\",sortSpecifiers:[{property:\"itemID\",direction:\"ascending\"}]})"); supplyItem.setSort(new SortSpecifier[] { new SortSpecifier(itemID.getName(), SortDirection.ASCENDING) }); supplyItem.fetchData(new AdvancedCriteria(new Criterion("itemName", OperatorId.STARTS_WITH, "Acc"))); w.addItem(supplyItem); IButton reloadBtn = new IButton("Reload data"); reloadBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { supplyItem.invalidateCache(); } }); w.addItem(reloadBtn); w.show(); } }
Code:
Please add this to field "itemID" in supplyItem.ds.xml: displayField="itemName"[B][/B]
- When you open the application, you'll see that the data loads, but is only sorted by the setSortByGroupFirst-groupBy-field in the DSRequest. (One field missing)
- If you click "Reload data", the data is requested again, but this time sorted by category and itemID(->itemName) (OK)
- If you enable row itemID.setDisplayField("itemName"); and reopen the window, the data is requested sorted by category and itemID(->itemName) (OK)
- If you disable itemID.setDisplayField("itemName"); again and also disable supplyItem.setGroupByField("category");, the data is loaded sorted by itemID(->itemName) (OK)
So the error is only occuring in a grouped ListGrid with a field, where the displayField is only set in .ds.xml.
I'm not sure if this is also related to the type of the field/displayField.
Tested in GC47 Compiled and FF26 Dev Mode.
Best regards
Blama
Comment