Hi Isomorphic,
I have a problem in my application (using v10.1p_2017-10-05) where a SectionStackSection controls-RadioGroupItem looses it's value after setting a new title for the section.
As you can see, with the setTitle() in DataArrivedHandler, the RadioGroupItem looses the value (both entries unselected). Without the setTitle()-call, it does not.
BuiltInDS.java:
Best regards
Blama
I have a problem in my application (using v10.1p_2017-10-05) where a SectionStackSection controls-RadioGroupItem looses it's value after setting a new title for the section.
As you can see, with the setTitle() in DataArrivedHandler, the RadioGroupItem looses the value (both entries unselected). Without the setTitle()-call, it does not.
BuiltInDS.java:
Code:
package com.smartgwt.sample.client;
import java.util.LinkedHashMap;
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.types.Alignment;
import com.smartgwt.client.types.OperatorId;
import com.smartgwt.client.types.VerticalAlignment;
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.Window;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.SectionStack;
import com.smartgwt.client.widgets.layout.SectionStackSection;
import com.smartgwt.client.widgets.layout.VLayout;
public class BuiltInDS extends VLayout implements EntryPoint {
private IButton recreateBtn;
private RadioGroupItem ageRGI;
private ListGrid animalsLG;
private SectionStackSection sss;
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("95%");
setHeight("95%");
setMembersMargin(0);
setModalMaskOpacity(70);
setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
setTitle("RadioGroupItem in SectionStackSection-controls looses it's value after SectionStackSection-title update" + getTitle());
setShowMinimizeButton(false);
setIsModal(true);
setShowModalMask(true);
centerInPage();
DynamicForm ageForm = new DynamicForm() {
{
setWidth(530);
// Resetting to default. (See DefaultApperanceSetter.setDynamicFormDefaultApperance())
setRequiredTitleSuffix(":");
ageRGI = new RadioGroupItem() {
{
setName("AGE");
setNumCols(2);
setTitle("Age");
setColWidths("*", "*");
setRequired(true);
setVertical(false);
LinkedHashMap<Boolean, String> optionMap = new LinkedHashMap<Boolean, String>();
optionMap.put(false, "<= 20");
optionMap.put(true, ">20");
setValueMap(optionMap);
setDefaultValue(true);
setRedrawOnChange(true);
addChangedHandler(new AnimalAgeChangedHandler());
}
};
setFields(ageRGI);
}
};
SectionStack ss = new SectionStack();
sss = new MySectionStackSection();
sss.setTitle("Animals");
animalsLG = new AnimalsLG(true, sss);
sss.setItems(animalsLG);
sss.setControls(ageForm);
ss.setSections(sss);
addItem(ss);
}
}
private class AnimalsLG extends ListGrid {
public AnimalsLG(boolean older20, final SectionStackSection parentSectionStackSection) {
super(DataSource.get("animals"));
setWidth(1000);
setHeight(500);
setAutoFetchData(false);
setAutoFitExpandField("commonName");
ListGridField lifeSpanLGF = new ListGridField("lifeSpan");
ListGridField commonNameLGF = new ListGridField("commonName");
ListGridField statusLGF = new MyLGF("status");
setFields(commonNameLGF, lifeSpanLGF, statusLGF);
setSortField("commonName");
addDataArrivedHandler(new DataArrivedHandler() {
@Override
public void onDataArrived(DataArrivedEvent event) {
SC.logInfo("Animals (" + getResultSet().getLength() + ")");
parentSectionStackSection.setTitle("Animals (" + getResultSet().getLength() + ")");
}
});
if (older20)
fetchData(new AdvancedCriteria(new Criterion("lifeSpan", OperatorId.GREATER_THAN, "20")));
else
fetchData(new AdvancedCriteria(new Criterion("lifeSpan", OperatorId.LESS_OR_EQUAL, "20")));
;
}
}
private class MySectionStackSection extends SectionStackSection {
@Override
public void setControls(Canvas... controls) {
HLayout hLayout = new HLayout(5);
hLayout.setAlign(Alignment.RIGHT);
hLayout.setLayoutRightMargin(10);
hLayout.setHeight(39);
for (Canvas s : controls) {
VLayout vLayout = new VLayout(0);
vLayout.setHeight(39);
vLayout.setAlign(VerticalAlignment.CENTER);
vLayout.setMembers(s);
hLayout.addMember(vLayout);
}
super.setControls(hLayout);
}
}
private final class AnimalAgeChangedHandler implements ChangedHandler {
@Override
public void onChanged(ChangedEvent event) {
boolean onPicklist = Boolean.valueOf(ageRGI.getValue().toString());
if (animalsLG != null) {
sss.setItems();
animalsLG.destroy();
}
animalsLG = new AnimalsLG(onPicklist, sss);
sss.setItems(animalsLG);
sss.setExpanded(true);
}
}
}
Blama
Comment