Hi Isomorphic,
I have a ListGrid, thats grouped by a Field. What I want to achieve is the following:
1. The ListGrid starts with GroupStartOpen.NONE, so all groups are collapsed. Groups open total: 0
2. The User opens one group. Groups open total: 1
3. The User opens another Group, but now the former opened Group must collapse Groups open total: 1
A maximum of one group may be open.
Setup: SmartClient Version: v12.0p_2018-09-04/PowerEdition Deployment (built 2018-09-04)
Browser : Chrome
I tried this, to get the functionality:
Unfortunately, this doesn´t work, its result is that all groups are colapsed. Can you please give some advice?
Regarding to this post, https://forums.smartclient.com/forum...groupstartopen
a Handler for the open/closed state of the groups would be nice.
Kind Regards
I have a ListGrid, thats grouped by a Field. What I want to achieve is the following:
1. The ListGrid starts with GroupStartOpen.NONE, so all groups are collapsed. Groups open total: 0
2. The User opens one group. Groups open total: 1
3. The User opens another Group, but now the former opened Group must collapse Groups open total: 1
A maximum of one group may be open.
Setup: SmartClient Version: v12.0p_2018-09-04/PowerEdition Deployment (built 2018-09-04)
Browser : Chrome
I tried this, to get the functionality:
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.SortSpecifier;
import com.smartgwt.client.types.GroupStartOpen;
import com.smartgwt.client.types.SelectionStyle;
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.grid.events.CellClickEvent;
import com.smartgwt.client.widgets.grid.events.CellClickHandler;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeNode;
public class BuiltInDS extends VLayout implements EntryPoint {
private IButton recreateBtn;
private final String fakeLGFName = "fakeLGFName";
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();
}
});
setWidth100();
setHeight100();
recreateBtn = new IButton("Recreate");
recreateBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
new MyWindow().show();
}
});
addMember(recreateBtn);
new MyWindow().show();
draw();
}
private class MyWindow extends Window {
public MyWindow() {
setWidth(400);
setHeight(600);
setMembersMargin(0);
setModalMaskOpacity(70);
setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
SC.logWarn(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
setShowMinimizeButton(false);
// setIsModal(true);
// setShowModalMask(true);
centerInPage();
VLayout vL = new VLayout();
// Img svgImg = new Img("http://127.0.0.1:8888/builtinds/tools/images/kiwi.svg", 100, 100);
ListGrid lg = new ListGrid() {
{
setSelectionType(SelectionStyle.SINGLE);
setVirtualScrolling(true);
setShowRecordComponents(true);
setShowRecordComponentsByCell(true);
// Records becomes unreadable every next click in 12.0. version, we don't expect many record so this is fine solution.
// setRecordComponentPoolingMode(RecordComponentPoolingMode.RECYCLE);
setPoolComponentsPerColumn(true);
setFixedRecordHeights(true);
setRecordComponentHeight(56);
setCanSort(false);
setCanPickFields(false);
setCanResizeFields(false);
setCanAutoFitFields(false);
setCanGroupBy(false);
setAutoFetchData(false);
setDataSource("animals");
ListGridField scientificNameLGF = new ListGridField(fakeLGFName);
ListGridField lifeSpanLGF = new ListGridField("lifeSpan");
ListGridField endangered = new ListGridField("status");
endangered.setHidden(true);
lifeSpanLGF.setCanEdit(true);
setFields(endangered, scientificNameLGF, lifeSpanLGF);
setGroupByField(endangered.getName());
setGroupStartOpen(GroupStartOpen.NONE);
setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) });
fetchData();
addCellClickHandler(new CellClickHandler() {
@Override
public void onCellClick(CellClickEvent event) {
Tree a = getGroupTree();
boolean changedOpen = true;
while (changedOpen) {
changedOpen = false;
for (TreeNode n : a.getAllNodes()) {
if (n.getAttribute("groupName") != null && n.getAttribute("groupName").equals("status")
&& n.getAttribute("singleCellValue") != null) {
SC.logWarn(event.getRecord().getAttribute("singleCellValue"));
if (!n.getAttribute("singleCellValue").equals(event.getRecord().getAttribute("singleCellValue"))) {
if (a.isOpen(n)) {
a.closeFolder(n);
changedOpen = true;
}
} else {
if (!a.isOpen(n)) {
a.openFolder(n);
changedOpen = true;
}
}
}
}
}
event.cancel();
}
});
}
};
vL.addMembers(lg);
addItem(vL);
}
}
}
Regarding to this post, https://forums.smartclient.com/forum...groupstartopen
a Handler for the open/closed state of the groups would be nice.
Kind Regards
Comment