Hi Isomorphic,
I have a case where a top-SelectItem in a ValuesManager-managed DynamicForm decides what to display in the detailForms below.
These forms are cleared on change of the top from. The problem is that I think that because of the ValueManager I'm not allowed to use detailForms.clearValues().
But I don't want to use myVM.clearValues().
When using detailForms.clearValues() I get a problem with myVM.valuesHaveChanged(), that I need as well.
Please see this v10.1p_2016-07-08 based testcase, that illustrates the problem (buttons shows false even after change).
BuiltInDS.java:
How to solve this best?
I could clear the form by listing the fields one by one in clearValue(java.lang.String fieldName), but I'd like it better if I could use the code as-is.
Or could you create a new overload clearValues(DynamicForm formToClear) in ValuesManager?
Another enhancement:
Could add warnings in DynamicForm with a ValuesManager if APIs are used that should not be used in this case?
Thank you & Best regards
Blama
I have a case where a top-SelectItem in a ValuesManager-managed DynamicForm decides what to display in the detailForms below.
These forms are cleared on change of the top from. The problem is that I think that because of the ValueManager I'm not allowed to use detailForms.clearValues().
But I don't want to use myVM.clearValues().
When using detailForms.clearValues() I get a problem with myVM.valuesHaveChanged(), that I need as well.
Please see this v10.1p_2016-07-08 based testcase, that illustrates the problem (buttons shows false even after change).
BuiltInDS.java:
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.DataSource; 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.DynamicForm; import com.smartgwt.client.widgets.form.ValuesManager; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; 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.setWidth(200); recreateBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { recreate(true); } }); mainLayout.addMembers(recreateBtn); mainLayout.draw(); } private void recreate(boolean allowEmptyValue) { Window w = new Window(); w.setWidth("95%"); w.setHeight("95%"); w.setMembersMargin(0); w.setModalMaskOpacity(70); w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")"); w.setTitle("SelectItem-change does not shown by ValuesManager" + w.getTitle()); w.setShowMinimizeButton(false); w.setIsModal(true); w.setShowModalMask(true); w.centerInPage(); final ValuesManager vM = new ValuesManager(); final DynamicForm invisibleDF = new DynamicForm(); invisibleDF.setWidth(250); invisibleDF.setIsGroup(true); DynamicForm selectEmp = new DynamicForm(); selectEmp.setWidth(250); selectEmp.setIsGroup(true); selectEmp.setValuesManager(vM); SelectItem employeeSI = new EmployeeSI("EmployeeId", allowEmptyValue); employeeSI.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { invisibleDF.clearValues(); // Configure invisibleDF fields (MANY FIELDS) // Add invisibleDF to main layout if not done already } }); selectEmp.setFields(employeeSI); invisibleDF.setValuesManager(vM); IButton checkChanges = new IButton("Check Changes"); checkChanges.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { SC.say(vM.valuesHaveChanged().toString()); } }); w.addItem(selectEmp); w.addItem(checkChanges); w.show(); } private class ListGridFieldHidden extends ListGridField { public ListGridFieldHidden(String name) { super(name); setHidden(true); } } private class EmployeeSI extends SelectItem { public EmployeeSI(String name, boolean allowEmptyValue) { super(name); setTitle("Employee"); setOptionDataSource(DataSource.get("employees")); setValueField("EmployeeId"); setDisplayField("Name"); setSortField("Name"); setRequired(true); setValidateOnChange(true); ListGridField empname = new ListGridField("Name"); ListGridFieldHidden EmployeeId = new ListGridFieldHidden("EmployeeId"); ListGridFieldHidden EmployeeType = new ListGridFieldHidden("EmployeeType"); ListGridField Gender = new ListGridField("Gender"); setPickListFields(EmployeeId, empname, EmployeeType, Gender); } } }
I could clear the form by listing the fields one by one in clearValue(java.lang.String fieldName), but I'd like it better if I could use the code as-is.
Or could you create a new overload clearValues(DynamicForm formToClear) in ValuesManager?
Another enhancement:
Could add warnings in DynamicForm with a ValuesManager if APIs are used that should not be used in this case?
Thank you & Best regards
Blama
Comment