0

I have a SelectItem component attached to a Dynamic form. the component has a valueMap set and there is no explicit operator set by me. According to the Smart GWT java docs, the default search operator for fields in a form that produces a AdvancedCriteria is "iContains" but it does not apply to special fields where exact match is obviously the right default setting, such as fields of type:"enum", or fields with a valueMap or optionDataSource.

https://smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/form/fields/FormItem.html#getOperator--

https://smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/form/DynamicForm.html#getDefaultSearchOperator--

I should be getting "equals" operator but instead i'm getting "iContains". Am I missing any configuration? What am I doing wrong? I'll be greatly appreciative of your help.

Code Sample:

SelectItem selectItem = new SelectItem(WorkDS.STATUS, "Status");
selectItem.setValueMap("SCHEDULED", "COMPLETED", "VERIFIED");
selectItem.setWidth("150");

setting the form items: form.setItems(...,selectItem,....);

I'm getting the AdvancedCriteria through the method DynamicForm.getValuesAsAdvancedCriteria()

AdvancedCriteria ac = form.getValuesAsAdvancedCriteria();

I did some digging and found out that earlier Smart GWT used to return "equals" operator if the field has a valueMap, or a optionDatasource etc. Inline with the documentation. But in the latest version (v13) it first gets the default operator ("iContains") based on the field type which is 'text' and then performs some checks and based on that decides whether to return "equals" or the default operator.

it gets the default operator

_4 = isc.SimpleType.getDefaultOperator(this.getType())

then goes on to perform the check below. _5 is set to true only of we have a operator set for the field, which in my case is false. _3 remains undefined. allowExpressions property is not set on my form so it is false. _4 is equal to "iContains". _7 evaluates to be true.

var _7 = _3 || _5 || (!_5 && _4 && !(this.form && this.form.allowExpressions && _4 == "iContains"));
 _4 = this.$199l(_1, _2, _7, _4);
$199l = function FormItem__getDefaultOperator(_1, _2, _3, _4) {
        var _5 = this.getValidOperators();
        var _6 = this.getType();
        if (this.valueMap || this.optionDataSource || SimpleType.inheritsFrom(_6, "enum") || SimpleType.inheritsFrom(_6, "boolean") || SimpleType.inheritsFrom(_6, "float") || SimpleType.inheritsFrom(_6, "integer") || SimpleType.inheritsFrom(_6, "date") || SimpleType.inheritsFrom(_6, "datetime") || SimpleType.inheritsFrom(_6, "time")) {
            return _3 ? _4 : "equals"
        } else {
            var _7 = _3 ? null : "iContains";
            if (this.form) {
                _7 = this.form.defaultSearchOperator || (_3 ? null : (this.form.allowExpressions ? "iContainsPattern" : "iContains"));
                var _8 = this.form.getDataSource()
                  , _9 = _8 && _8.getFieldOperators(this.name)
                  , _10 = _9 && _9.contains(_7);
                if (!_10 && _9) {
                    if (_3)
                        return _4;
                    _7 = _9[0]
                }
            }
            return DataSource.getCriteriaOperator(null, _1, _7, _3) || _4
        }
    }

here it checks for the valueMap and returns the operator based on _3 which is the same value as _7.

I don't want to change my code since then I'd have to make changes in several places. I expect the framework to return "equals" operator for the fields for which a valueMap is set, and as mentioned in the documents. Does anyone else have come across this issue? if yes, were you able to resolve it? Any kind of help is appreciated.

0 Answers0