Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    patch for getCellValidators

    Hi there, I found a patch was needed to avoid incorrect validators being applied to my ListGrid in SC 12.0. I tried to recreate this in your samples and I could not and can't invest anymore time. But, the patch is common-sense so I think you should consider applying it. Basically, the patch below shows that the editItem for the cell validator was the wrong edit item. This happened when the last cell the user entered was for an integer field in the third position in the grid it was applying the validator for that integer field to my boolean field in the first position in the grid. The patch below just confirms the field.name and the editItem.name are the same before applying the editItem.validators

    Code:
        isc.ListGrid.getPrototype().addProperties({
    
            getCellValidators : function isc_ListGrid_getCellValidators(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);
                    //patch to ensure the editItem field name and field name match before applying validators from the edit Item
                    if (editItem && editItem.name==field.name) 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;
            }
    
    })

    #2
    Hmm - it appears you may be using a stale build and looking at an issue that's already been resolved.

    In both the 12.0 and 12.1 branches the default implementation for getCellValidators() should already be picking up the edit item by field name rather than colNum


    In other words this conditional

    Code:
    ...
     if (editForm) {
        var editItem = editForm.getItem(colNum);
        //patch to ensure the editItem field name and field name match before applying validators from the edit Item
        if (editItem && editItem.name==field.name) itemValidators = editItem.validators;
     }
     ...
    Looks like this in the (latest) shipped code:

    Code:
        ...
        if (editForm) {
            var fieldName = field[this.fieldIdProperty],
            editItem = editForm.getItem(fieldName);
            if (editItem) itemValidators = editItem.validators;
        }
        ....
    As such the patch should not be necessary if you have a recent build.

    Please let us know if this doesn't match what you're seeing

    Regards Isomorphic Software

    Comment


      #3
      Hi, we are running 12.0 from 5/14/19. Is it safe to assume you fixed this issue since then?

      Comment


        #4
        We had a developer take a look and, yes, it looks like this fix went in shortly after the build you're on.

        Comment

        Working...
        X