Hi Isomorphic,
please run this sample (v10.1p_2017-03-02).
As you can see, the number for the group nodes is one more than expected for each male/female. This is because the groupSummaryRow is included in groupNode.getGroupMembers(). Is this expected?
If it is expected, this heals it for me, but I'm not sure I should need to fix it in the 1st place:
Also, as convenience you could disable creating a default summaryFuntion for integer fields, if the field is a PK or FK field. I'm pretty sure generating it is wrong more often than it is correct.
Best regards
Blama
please run this sample (v10.1p_2017-03-02).
As you can see, the number for the group nodes is one more than expected for each male/female. This is because the groupSummaryRow is included in groupNode.getGroupMembers(). Is this expected?
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.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.form.fields.ComboBoxItem; import com.smartgwt.client.widgets.grid.GroupNode; import com.smartgwt.client.widgets.grid.GroupTitleRenderer; 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(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")"); w.setTitle("TITLE" + w.getTitle()); w.setShowMinimizeButton(false); w.setIsModal(true); w.setShowModalMask(true); w.centerInPage(); final ListGrid employeesGrid = new ListGrid(); employeesGrid.setHeight100(); employeesGrid.setAutoFetchData(false); employeesGrid.setCanEdit(true); employeesGrid.setDataSource(DataSource.get("employees")); employeesGrid.setCanGroupBy(true); employeesGrid.setGroupStartOpen(GroupStartOpen.ALL); ListGridField employeeId = new ListGridField("EmployeeId"); employeeId.setCanEdit(false); ListGridField name = new ListGridField("Name"); name.setCanEdit(false); ListGridField gender = new ListGridField("Gender"); gender.setGroupTitleRenderer(new GroupTitleRenderer() { public String getGroupTitle(Object groupValue, GroupNode groupNode, ListGridField field, String fieldName, ListGrid grid) { return (String) groupValue + " (" + groupNode.getGroupMembers().length + ")"; } }); gender.setCanGroupBy(true); employeesGrid.setShowGridSummary(true); // Enable/Disable this row employeesGrid.setShowGroupSummary(true); ListGridField reportsTo = new ListGridFieldReportsTo("ReportsTo"); reportsTo.setHidden(false); ListGridField job = new ListGridField("Job"); employeesGrid.setFields(employeeId, name, gender, reportsTo, job); employeesGrid.setSort(new SortSpecifier[] { new SortSpecifier(name.getName(), SortDirection.ASCENDING) }); employeesGrid.setGroupByField(gender.getName()); employeesGrid.fetchData(new AdvancedCriteria(new Criterion(name.getName(), OperatorId.STARTS_WITH, "Ab"))); w.addItem(employeesGrid); w.show(); } private class ListGridFieldReportsTo extends ListGridField { public ListGridFieldReportsTo(String name) { super(name); ComboBoxItem managerCBI = new ComboBoxItem(); managerCBI.setOptionDataSource(DataSource.get("employees")); managerCBI.setOptionOperationId("foobar"); managerCBI.setValueField(DataSource.get("employees").getPrimaryKeyFieldName()); managerCBI.setDisplayField("Name"); managerCBI.setPickListSort(new SortSpecifier[] { new SortSpecifier("EmployeeId", SortDirection.ASCENDING), new SortSpecifier("Name", SortDirection.ASCENDING) }); ListGridField managerCBI_empIdLGF = new ListGridField("EmployeeId"); ListGridField managerCBI_nameLGF = new ListGridField("Name"); managerCBI.setPickListFields(managerCBI_empIdLGF, managerCBI_nameLGF); managerCBI.setPickListHeaderHeight(0); setEditorProperties(managerCBI); } } }
Code:
gender.setGroupTitleRenderer(new GroupTitleRenderer() { public String getGroupTitle(Object groupValue, GroupNode groupNode, ListGridField field, String fieldName, ListGrid grid) { return (String) groupValue + " (" + [B](groupNode.getGroupMembers().length - (grid.getShowGroupSummary() ? 1 : 0))[/B] + ")"; } });
Best regards
Blama
Comment