Hi Isomorphic,
please see this testcase (v10.0p_2015-05-21) which closely resembles my application setup.
When you click the column headers, the data in the groups is resorted accordingly, but the groups themselves are not. Note that I do use ListGrid.setSortByGroupFirst(true) but do not use ListGrid.setGroupSortDirection(), so they should be resorted.
From my gut feeling creating the testcase this is somehow related to datatypes and datatype-conversion.
It does not matter if the ListGrid is set up with setXState() or setSort(), but is does make a difference if inital sorting is ASC or DESC (see the first two buttons and the 1st group for each).
BuiltInDS.java:
StatusLGF.java:
Testcase is created with v10.0p_2015-05-21 and FF26 Dev Mode, but in my application the issue shows up deployed in GC42/FF26/IE11 as well.
Best regards
Blama
please see this testcase (v10.0p_2015-05-21) which closely resembles my application setup.
When you click the column headers, the data in the groups is resorted accordingly, but the groups themselves are not. Note that I do use ListGrid.setSortByGroupFirst(true) but do not use ListGrid.setGroupSortDirection(), so they should be resorted.
From my gut feeling creating the testcase this is somehow related to datatypes and datatype-conversion.
It does not matter if the ListGrid is set up with setXState() or setSort(), but is does make a difference if inital sorting is ASC or DESC (see the first two buttons and the 1st group for each).
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.GroupStartOpen; 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("setSortDesc"); hL = new HLayout(5); hL.setHeight(40); IButton reloadSetSortAsc = new IButton("Reload SetSortAsc"); reloadSetSortAsc.setWidth(150); reloadSetSortAsc.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { vL.removeChild(tG); tG.markForDestroy(); tG = new TestGrid("setSortAsc"); vL.addMember(tG, 0); } }); IButton reloadSetSortDesc = new IButton("Reload SetSortDesc (Default)"); reloadSetSortDesc.setWidth(150); reloadSetSortDesc.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { vL.removeChild(tG); tG.markForDestroy(); tG = new TestGrid("setSortDesc"); vL.addMember(tG, 0); } }); IButton reloadSetStates = new IButton("Reload SetStates"); reloadSetStates.setWidth(150); reloadSetStates.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { vL.removeChild(tG); tG.markForDestroy(); tG = new TestGrid("useStates"); vL.addMember(tG, 0); } }); IButton getFieldState = new IButton("Get FieldState"); getFieldState.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { SC.say("FieldState", tG.getFieldState()); } }); IButton getSortState = new IButton("Get SortState"); getSortState.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { SC.say("SortState", tG.getSortState()); } }); hL.addMembers(reloadSetSortAsc, reloadSetSortDesc, reloadSetStates, getFieldState, getSortState); vL.addMembers(tG, hL); vL.draw(); } private class TestGrid extends ListGrid { StatusLGF status; ListGridField commonName; ListGridField diet; ListGridField lifeSpan; public TestGrid(String mode) { super(); setAutoFetchData(false); setGroupStartOpen(GroupStartOpen.ALL); setSortByGroupFirst(true); setDataSource(DataSource.get("animals")); status = new StatusLGF("status"); status.setHidden(true); commonName = new ListGridField("commonName"); diet = new ListGridField("diet"); lifeSpan = new ListGridField("lifeSpan"); setGroupByField(status.getName()); setFields(status, commonName, diet, lifeSpan); if (mode.equals("useStates")) { setFieldState("[{name:\"status\",visible:false},{name:\"commonName\"},{name:\"diet\"},{name:\"lifeSpan\"}]"); setSortState("({fieldName:\"diet\",sortDir:\"descending\",sortSpecifiers:[{property:\"diet\",direction:\"descending\"}]})"); } else if (mode.equals("setSortDesc")){ setSort(new SortSpecifier[] { new SortSpecifier(diet.getName(), SortDirection.DESCENDING) }); } else if (mode.equals("setSortAsc")){ setSort(new SortSpecifier[] { new SortSpecifier(diet.getName(), SortDirection.ASCENDING) }); } fetchData(); } } }
Code:
package com.smartgwt.sample.client; import com.smartgwt.client.widgets.grid.GroupNode; import com.smartgwt.client.widgets.grid.GroupTitleRenderer; import com.smartgwt.client.widgets.grid.GroupValueFunction; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.grid.SortNormalizer; public class StatusLGF extends ListGridField { final String sortField; public StatusLGF(String name) { super(name); sortField = "lifeSpan"; setSortNormalizer(new SortNormalizer() { @Override public Object normalize(ListGridRecord record, String fieldName) { if (record.getAttributeAsInt(sortField) == null) return new Integer(0); else return record.getAttributeAsInt(sortField); } }); setGroupValueFunction(new GroupValueFunction() { @Override public Object getGroupValue(Object value, ListGridRecord record, ListGridField field, String fieldName, ListGrid grid) { if (record.getAttributeAsInt(sortField) == null) return new Integer(0); else return record.getAttributeAsInt(sortField); } }); setGroupTitleRenderer(new GroupTitleRenderer() { @Override public String getGroupTitle(Object groupValue, GroupNode groupNode, ListGridField field, String fieldName, ListGrid grid) { int i = groupNode.getGroupMembers().length; String groupName = "Lifespan: " + groupNode.getGroupMembers()[0].getAttributeAsString(sortField) + " years"; return groupName + " (" + i + ((i == 1) ? " animal)" : " animals)"); } }); } }
Best regards
Blama
Comment