Hi Isomorphic,
please see this builtInDS-based testcase using 5.1d SNAPSHOT_v10.1d_2015-10-30, where the validation for the name-field does not take place when name is the only editable field in the row.
If you comment out the setCanEdit(false) in ListGridFieldNoEdit, everything works as expected.
I have the same approach (based on grid_custom_editing_cell) in use for my settings-table where I store data as varchar, but depending on the row show different FormItems or TextItems with a validator as UI elements like in this thread.
BuiltInDS.java:
Best regards
Blama
please see this builtInDS-based testcase using 5.1d SNAPSHOT_v10.1d_2015-10-30, where the validation for the name-field does not take place when name is the only editable field in the row.
If you comment out the setCanEdit(false) in ListGridFieldNoEdit, everything works as expected.
I have the same approach (based on grid_custom_editing_cell) in use for my settings-table where I store data as varchar, but depending on the row show different FormItems or TextItems with a validator as UI elements like in this thread.
BuiltInDS.java:
Code:
package com.smartgwt.sample.client; import com.google.gwt.core.client.EntryPoint; 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.OperatorId; 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.TextItem; import com.smartgwt.client.widgets.form.validator.RegExpValidator; 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 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.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { recreate(); } }); mainLayout.addMember(recreateBtn); recreate(); mainLayout.draw(); } private void recreate() { Window w = new Window(); w.setWidth("95%"); w.setHeight("95%"); w.setMembersMargin(0); w.setModalMaskOpacity(70); w.setTitle("No validation on tab"); w.setShowMinimizeButton(false); w.setIsModal(true); w.setShowModalMask(true); w.centerInPage(); { final ListGrid testGrid = new ListGrid(DataSource.get("employees")); testGrid.setCanEdit(true); ListGridField genderLGF = new ListGridFieldNoEdit("Gender"); ListGridField nameLGF = new ListGridField("Name"); ListGridField jobLGF = new ListGridFieldNoEdit("Job"); ListGridField emailLGF = new ListGridFieldNoEdit("Email"); ListGridField employeeTypeLGF = new ListGridFieldNoEdit("EmployeeType"); ListGridField employeeStatusLGF = new ListGridFieldNoEdit("EmployeeStatus"); ListGridField salaryLGF = new ListGridFieldNoEdit("Salary"); ListGridField orgUnitLGF = new ListGridFieldNoEdit("OrgUnit"); ListGridField maritalStatusLGF = new ListGridFieldNoEdit("MaritalStatus"); testGrid.setFields(genderLGF, nameLGF, jobLGF, emailLGF, employeeTypeLGF, employeeStatusLGF, salaryLGF, orgUnitLGF, maritalStatusLGF); testGrid.setEditorCustomizer(new ListGridEditorCustomizer() { public FormItem getEditor(ListGridEditorContext context) { ListGridField field = context.getEditField(); if (field.getName().equals("Name")) { TextItem editNameTI = new TextItem("Name"); RegExpValidator aToMValidator = new RegExpValidator("^[A-Ma-m].*$"); editNameTI.setValidators(aToMValidator); editNameTI.setValidateOnExit(true); return editNameTI; } else return context.getDefaultProperties(); } }); AdvancedCriteria ac = new AdvancedCriteria(new Criterion("Name", OperatorId.STARTS_WITH, "A")); testGrid.fetchData(ac); w.addItem(testGrid); } w.show(); } private class ListGridFieldNoEdit extends ListGridField { public ListGridFieldNoEdit(String name) { super(name); setCanEdit(false); } } }
Blama
Comment