Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

[Bug] ComboBoxItem: wrong criteria is sent to server on item pick up.

$
0
0
Hi,

I've found that ComboBoxItem which is bounded to DataSource is behaving somehow incorrectly.


Code:

Theory:
valueMap            - a dictionary how to map input string to ID (with data bound it's implemented differently, but logical the same)
getValue()          - real value of ComboBoxItem will return ID if found in valueMap or the same value as getEnteredValue()
getEnteredValue() - value of ComboBoxItem which is entered or selected by user (string)
displayFieldName  - is field name which will be searched by if input is not found in picklist
valueFieldName    - is field name which stores real value for ComboBoxItem  (basically it`s primary key of datasource)

If ComboBox will find `getEnteredValue()` in it's `valueMap` then resolved ID will be used,
but if not found then ComboBox will trigger fetchData on DataSource with criteria := {displayFieldName: getEnteredValue()}.

The problem is that ComboBox now is triggering fetchData with criteria := {displayFieldName: getValue()} instead and our datasource can't find any records with "name"=2

Firstly I cannot find out why ComboBox triggers that fetch at all because I've picked up item from drop down.

Bug is here:
Code:

//ComboBoxItem.js at handleEditorExit method:

                // Otherwise, consider the value to be a display value. If we have an ODS and
                // display field, check whether we have a data value for it. If not, try to fetch
                // a data value for this display value using _checkForValueFieldValue().
                } else if (ods != null && displayField != null
                          && elementValue != null && elementValue != "" &&
                          this.shouldFetchMissingDisplayValue(elementValue)
                          )
                {
                    this._checkForValueFieldValue(value); // <- Here must be an elementValue not a value.
                }

Please fix this then you'll have time.

PS.

I've analyzed why ComboBox triggers that fetch at all and found that `this.shouldFetchMissingDisplayValue(elementValue)`
is returning true.

FormItem._shouldFetchMissingValue(..): in this._displayFieldCache object I see only one record instead of full picklist record set.
Shouldn't be this method related with `mapDisplayToValue()` method? because input value mapping to ID is done by this method not by some _displayFieldCache object? if _displayFieldCache is cleared `mapDisplayToValue()` works correctly but that _shouldFetchMissingValue() returns false - not logical.

Thanks.



Affected versions:
all versions including SmartClient_v100p_2015-05-21

Viewing all articles
Browse latest Browse all 4756

Trending Articles