Question

I have a form which uses CustomValidator to check for non empty field whenever we try to Add a record (PARAMETER, VALUE) I'm looking for a way to disable form validation when I'm trying to Delete (the user can delete an empty listGridRecord if he changes his mind and needs no more to add).

I'm using this custom validator:

    CustomValidator validatorParameter = new CustomValidator() {

        @Override
        protected boolean condition(Object value) {

            parameterName = (String) value;
            if ((value == null || ((String) value).trim().isEmpty())) {
                rowIsValidate = false;
                return false;
            } else {
                rowIsValidate = true;
                return true;
            }
        }
    };

which I'm setting in an init() method this way:

parametersListGrid.getField(PARAMETER).setValidators(validatorParameter);

I tried setting a flag "noValidation" on true whenever I detect a click on Delete button and used it this way:

CustomValidator validatorParameter = new CustomValidator() {

        @Override
        protected boolean condition(Object value) {

            parameterName = (String) value;
            if (((value == null || ((String) value).trim().isEmpty())) && !noValidation){
                rowIsValidate = false;
                return false;
            } else {
                rowIsValidate = true;
                return true;
            }
        }
    };

but I figured out that this flag is set later on after the validation happened so rowIsValidate stays false and we can't delete the empty record given the errors shown after validation;

Any idea on how to pass this validation step just in deletion scenario?

Was it helpful?

Solution

Call discardEdits(rowNum) before deleting a record.

Same question is asked on SmartClient Forums.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top