Hi Isomorphic,
how is this usecase best solved (using current 5.0p, v10.0p_2015-10-08):
I have a ListGrid displaying many columns, therefore width is valueable.
I have a column that is always grouped and has useful information in the groupHeader, but also the group value. Therefore I hide the column itself. Now, if the data returned is more than setGroupByMaxRecords(), I have the problem that the informational groupHeader is not shown, but the column itself with its data is still hidden.
I tried addGroupByCompleteHandler and addGroupByHandler, where I assume that the former is the correct one. At least it fires asynchronously after grouping is complete on the client. It does not fire if the grouping does not take place because of the total number of records being larger than setGroupByMaxRecords() (see test case).
How do I notice best that I need to programmatically show the column? Can you make addGroupByCompleteHandler fire as well when grouping is unsuccessful (perhaps with some value parameter that grouping was unsuccessful)?
Should I use addDataArrivedHandler() and look at the total ResultSet length?
Thank you & Best regards
Blama
how is this usecase best solved (using current 5.0p, v10.0p_2015-10-08):
I have a ListGrid displaying many columns, therefore width is valueable.
I have a column that is always grouped and has useful information in the groupHeader, but also the group value. Therefore I hide the column itself. Now, if the data returned is more than setGroupByMaxRecords(), I have the problem that the informational groupHeader is not shown, but the column itself with its data is still hidden.
I tried addGroupByCompleteHandler and addGroupByHandler, where I assume that the former is the correct one. At least it fires asynchronously after grouping is complete on the client. It does not fire if the grouping does not take place because of the total number of records being larger than setGroupByMaxRecords() (see test case).
How do I notice best that I need to programmatically show the column? Can you make addGroupByCompleteHandler fire as well when grouping is unsuccessful (perhaps with some value parameter that grouping was unsuccessful)?
Should I use addDataArrivedHandler() and look at the total ResultSet length?
Code:
package com.smartgwt.sample.client; import com.google.gwt.core.client.EntryPoint; 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.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.grid.events.GroupByCompleteEvent; import com.smartgwt.client.widgets.grid.events.GroupByCompleteHandler; import com.smartgwt.client.widgets.grid.events.GroupByEvent; import com.smartgwt.client.widgets.grid.events.GroupByHandler; public class BuiltInDS implements EntryPoint { private IButton recreateBtn; private DataSource supplyItemDS = DataSource.get("supplyItem"); 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(); } }); recreateBtn = new IButton("Recreate"); recreateBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { recreate(); } }); recreate(); recreateBtn.draw(); } private void recreate() { Window w = new Window(); w.setWidth("95%"); w.setHeight("95%"); w.setMembersMargin(0); w.setModalMaskOpacity(70); w.setTitle("Grouping test"); w.setShowMinimizeButton(false); w.setIsModal(true); w.setShowModalMask(true); w.centerInPage(); ListGrid lg = new ListGrid(supplyItemDS); lg.setCanEdit(false); lg.setCanGroupBy(false); lg.setGroupByMaxRecords(90); lg.setAllowFilterExpressions(true); lg.setShowFilterEditor(true); lg.setAutoFetchData(false); lg.setGroupStartOpen(GroupStartOpen.ALL); lg.setCanGroupBy(true); lg.setCanReorderFields(true); ListGridField itemIdLGF = new ListGridField("itemID"); ListGridField itemNameLGF = new ListGridField("itemName"); ListGridField skuLGF = new ListGridField("SKU"); ListGridField descriptionLGF = new ListGridField("description"); ListGridField categoryLGF = new ListGridField("category"); categoryLGF.setHidden(true); categoryLGF.setCanHide(false); ListGridField unitsLGF = new ListGridField("units"); lg.setSortByGroupFirst(true); lg.setGroupByField(categoryLGF.getName()); lg.setFields(itemIdLGF, itemNameLGF, skuLGF, descriptionLGF, categoryLGF, unitsLGF); lg.setSort(new SortSpecifier[] { new SortSpecifier(itemIdLGF.getName(), SortDirection.ASCENDING), new SortSpecifier(itemNameLGF.getName(), SortDirection.ASCENDING) }); lg.addGroupByCompleteHandler(new GroupByCompleteHandler() { @Override public void onGroupByComplete(GroupByCompleteEvent event) { SC.logWarn("GroupByCompleteHandler: " + event.toDebugString()); } }); lg.addGroupByHandler(new GroupByHandler() { @Override public void onGroupBy(GroupByEvent event) { SC.logWarn("GroupByHandler: " + event.toDebugString()); } }); lg.fetchData(new Criterion(itemIdLGF.getName(), OperatorId.LESS_OR_EQUAL, 100)); w.addItem(lg); w.show(); } }
Blama
Comment