Hi,
In the following test case matchFieldValidator is set (the "validTo" field). This validator depends on previous "validFrom" field value and is attached at the DataSourceField scope.
The DataSource is then used by DynamicForm and ListGrid.
If you run this example and change value of "validTo" field to some other value (both in form and in grid) and then press Validate, you got validation errors indicators in form and in grid - which is fine.
Run the example once again, but this time change value of "validFrom" field (both in form and in grid) and press Validate. This time validation error is shown only in form, grid's row editing does not trigger validation - which is wrong.
This is not the problem of matchesField validator only. Other validators (including custom validators), which are using dependentFields attribute, also shows this problem while grid editing and validation.
Thanks,
MichalG
SmartClient Version: v11.0p_2016-07-04/LGPL Development Only (built 2016-07-04)
Firefox 24.8.0, Chrominium 38.0.2125.101
In the following test case matchFieldValidator is set (the "validTo" field). This validator depends on previous "validFrom" field value and is attached at the DataSourceField scope.
The DataSource is then used by DynamicForm and ListGrid.
Code:
import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.data.Record; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.FieldType; import com.smartgwt.client.widgets.Button; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.events.DrawEvent; import com.smartgwt.client.widgets.events.DrawHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.validator.MatchesFieldValidator; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.layout.VLayout; import java.util.HashMap; public class MainEntryPoint implements EntryPoint { public void onModuleLoad() { layout(); } private void layout() { DataSource projectDS = new DataSource(); projectDS.setClientOnly(true); DataSourceField idField = new DataSourceField(); idField.setType(FieldType.SEQUENCE); idField.setName("id"); idField.setPrimaryKey(true); idField.setHidden(true); DataSourceTextField codeField = new DataSourceTextField(); codeField.setName("code"); DataSourceTextField validFromField = new DataSourceTextField(); validFromField.setName("validFrom"); DataSourceTextField validToField = new DataSourceTextField(); validToField.setName("validTo"); MatchesFieldValidator matchesValidator = new MatchesFieldValidator(); matchesValidator.setOtherField("validFrom"); // matchesValidator.setDependentFields(new String[] {"validFrom"}); validToField.setValidators(matchesValidator); projectDS.setFields(idField, codeField, validFromField, validToField); final DynamicForm df = new DynamicForm(); df.setDataSource(projectDS); // df.getField("id").setValue("0"); df.getField("validFrom").setValue("aa"); df.getField("validTo").setValue("aa"); final ListGrid lg = new ListGrid(); lg.setDataSource(projectDS); lg.setCanEdit(true); lg.setAutoSaveEdits(false); lg.setWidth(200); lg.addDrawHandler(new DrawHandler() { public void onDraw(DrawEvent event) { HashMap map = new HashMap(); map.put("id", "0"); map.put("validFrom", "aa"); map.put("validTo", "aa"); //lg.startEditingNew(map); Record[] records = new Record[1] ; records[0] = new Record(map); lg.setData(records); } }); Button validateButton = new Button("Validate"); validateButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { df.validate(); lg.validateRow(0); } }); VLayout layout = new VLayout(); layout.addMember(df); layout.addMember(lg); layout.addMember(validateButton); layout.draw(); } }
Run the example once again, but this time change value of "validFrom" field (both in form and in grid) and press Validate. This time validation error is shown only in form, grid's row editing does not trigger validation - which is wrong.
This is not the problem of matchesField validator only. Other validators (including custom validators), which are using dependentFields attribute, also shows this problem while grid editing and validation.
Thanks,
MichalG
SmartClient Version: v11.0p_2016-07-04/LGPL Development Only (built 2016-07-04)
Firefox 24.8.0, Chrominium 38.0.2125.101
Comment