SmartClient Version: v12.0p_2019-05-14/LGPL Development Only (built 2019-05-14)
Chrome Version 74.0.3729.157 (Official Build) (64-bit)
ListGrids configured for editByCell do not validate properly. After editing a cell other than the first, the first cell has validations corresponding to the edited cell.
Steps to reproduce:
1) Enter a non-numeric text like "test" into g1.
2) Edit g2 and enter a number like "123".
3) Exit the editor to trigger validation and observe g1 fails with "Must be whole number".
If you change logging on gridEdit to DEBUG, you'll see this:
If I change the code in ISC_Grids.js on line 54719 as follows, it appears to correct the behavior:
Chrome Version 74.0.3729.157 (Official Build) (64-bit)
ListGrids configured for editByCell do not validate properly. After editing a cell other than the first, the first cell has validations corresponding to the edited cell.
Code:
public class ValidationTestWindow2 extends Window
{
private static class GridDataSource extends DataSource
{
{
setClientOnly(true);
final DataSourceTextField g1 = new DataSourceTextField("g1");
g1.setRequired(true);
final DataSourceIntegerField g2 = new DataSourceIntegerField("g2");
g2.setRequired(true);
setFields(g1, g2);
}
}
private static class ValidationTestGrid extends ListGrid
{
ValidationTestGrid()
{
setDataSource(new GridDataSource());
setEditByCell(true);
final ListGridField g1 = new ListGridField("g1");
final ListGridField g2 = new ListGridField("g2");
setFields(g1, g2);
}
}
private class ValidationTestLayout extends VLayout
{
ValidationTestLayout()
{
setHeight(300);
setWidth(500);
final ValidationTestGrid grid = new ValidationTestGrid();
setMembers(grid);
addDrawHandler(drawEvent -> grid.startEditingNew());
}
}
ValidationTestWindow2()
{
setAutoSize(true);
addItem(new ValidationTestLayout());
}
}
1) Enter a non-numeric text like "test" into g1.
2) Edit g2 and enter a number like "123".
3) Exit the editor to trigger validation and observe g1 fails with "Must be whole number".
If you change logging on gridEdit to DEBUG, you'll see this:
Code:
09:32:35.598:KDN6:DEBUG:gridEdit:isc_ValidationTestWindow2_ValidationTestGrid_0:At field: g1 applying validators: [
{type: "isString",
typeCastValidator: true,
_generated: true,
_typeValidator: true,
defaultErrorMessage: undef},
{type: "required",
defaultErrorMessage: undef,
errorMessage: "Field is required"},
{type: "isInteger",
typeCastValidator: true,
_generated: true,
_typeValidator: true},
{type: "required"}
] to value:test
Code:
getCellValidators : function (rowNum, colNum) {
var field = this.getField(colNum);
if (!field) return null;
var itemValidators,
fieldValidators = field.validators,
editForm = this.getEditForm();
if (editForm) {
var editItem = editForm.getItem(colNum);[B] // change to this: var editItem = editForm.getItem(field.name);[/B]
if (editItem) itemValidators = editItem.validators;
}
if (fieldValidators && itemValidators) {
var combined = [];
for (var i = 0; i < fieldValidators.length; i++) {
var validator = fieldValidators[i];
if (!combined.contains(validator)) combined.add(validator);
}
for (var i = 0; i < itemValidators.length; i++) {
var validator = itemValidators[i];
if (!combined.contains(validator)) combined.add(validator);
}
return combined;
}
return fieldValidators || itemValidators || null;
},
Comment