Hi Isomorphic,
please take a look at this.
The same code for both ListGrids except "setShowPickerIconOnFocus(true)" in the class SelectItemYesNo.
This only applies when editing empty fields.
Best regards
Pavo
please take a look at this.
The same code for both ListGrids except "setShowPickerIconOnFocus(true)" in the class SelectItemYesNo.
This only applies when editing empty fields.
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.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.fields.FormItem; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridEditorContext; import com.smartgwt.client.widgets.grid.ListGridEditorCustomizer; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.layout.VLayout; public class BuiltInDS extends VLayout implements EntryPoint { 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(); } }); 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(300); setHeight(600); setMembersMargin(0); setModalMaskOpacity(70); setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")"); setShowMinimizeButton(false); setIsModal(true); setShowModalMask(true); centerInPage(); ListGridCustom withoutSetShowPickerIconOnFocusLG = new ListGridCustom(false); ListGridCustom withSetShowPickerIconOnFocusLG = new ListGridCustom(true); addItem(withoutSetShowPickerIconOnFocusLG); addItem(withSetShowPickerIconOnFocusLG); } } private class ListGridCustom extends ListGrid { public ListGridCustom(Boolean setShowPickerIconOnFocus) { setDataSource("animals"); setCanEdit(true); final SelectItemYesNo siyn = new SelectItemYesNo(setShowPickerIconOnFocus); setEditorCustomizer(new ListGridEditorCustomizer() { @Override public FormItem getEditor(ListGridEditorContext context) { return siyn; } }); ListGridField testLGF = new ListGridField("commonName"); ListGridField test2LGF = new ListGridField("scientificName"); setFields(testLGF, test2LGF); fetchData(); } } private class SelectItemYesNo extends SelectItem { public SelectItemYesNo(Boolean setShowPickerIconOnFocus) { final LinkedHashMap<String, String> vM = new LinkedHashMap<String, String>(); vM.put("Y", "Yes"); vM.put("N", "No"); setValueMap(vM); setAllowEmptyValue(true); if (setShowPickerIconOnFocus) setShowPickerIconOnFocus(true); else setShowPickerIconOnFocus(false); } } }
Pavo
Comment