Hi Isomorphic,
can you please take a look at this? On loading I have null exception on line 109 (resort();).
(v12.0p_2018-08-23/PowerEdition Deployment (built 2018-08-23))
So I think this is a bug, because this ListGrid has sort-specifier array.
Best regards
Pavo
can you please take a look at this? On loading I have null exception on line 109 (resort();).
(v12.0p_2018-08-23/PowerEdition Deployment (built 2018-08-23))
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.SortSpecifier; import com.smartgwt.client.types.OperatorId; 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.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Label; 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.ListGridRecord; import com.smartgwt.client.widgets.grid.events.DataChangedEvent; import com.smartgwt.client.widgets.grid.events.DataChangedHandler; import com.smartgwt.client.widgets.layout.VLayout; 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"); lifeSpanLGF.setCanEdit(true); setFields(scientificNameLGF, lifeSpanLGF); setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) }); setInitialSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) }); fetchData(new AdvancedCriteria(new Criterion("status", OperatorId.EQUALS, "Endangered"))); addDataChangedHandler(new DataChangedHandler() { @Override public void onDataChanged(DataChangedEvent event) { SortSpecifier[] ss = ((ListGrid) event.getFiringCanvas()).getSort(); SC.logWarn(ss.toString()); resort(); } }); } @Override protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) { String fieldName = this.getFieldName(colNum); if (fakeLGFName.equals(fieldName)) { String topicName = record.getAttributeAsString("scientificName"); Label testLabel = new Label(); testLabel.setContents(topicName); VLayout vLayout = new VLayout(6); vLayout.setHeight(50); vLayout.setWidth100(); vLayout.setMembers(testLabel); return vLayout; } else return null; } }; vL.addMembers(lg); addItem(vL); } } }
Best regards
Pavo
Comment