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

SimpleType - editFormatter

$
0
0
Version : SmartClient_v91p_2014-07-18_Pro

We have created our own simpleType and added it some formattign rules by extending editFormatter, shortDisplayFormatter and normalDisplayFormatter (cf. MeiSimpleMoney in attachment).

When we are in a ListGrid, the value is well formatted (our rules are applied), but when we open the item for edition (i.e. we create a dynamicForm to edit the value), we have a scripting error with this SmartClient version (with the version we used before - v9.0p_2014-01-24/Pro, we have no issue).

In v9.1p, the method FloatItem.mapValueToDisplay has been changed
Code:

isc.FloatItem.addMethods({

    // Note: similar code appears in StaticTextItem
    mapValueToDisplay : function (value) {
        if (!this._inEditorMode) {
            var floatValue = null;
            if (isc.isA.String(value) && (this.type == null || !this.type.startsWith("locale"))) {
                var parsedValue = window.parseFloat(value);
                if (!window.isNaN(parsedValue) && parsedValue == value) {
                    floatValue = parsedValue;
                }
            } else if (isc.isA.Number(value)) {
                floatValue = value;
            }
            if (floatValue != null) {
                if (this.format) {
                    return isc.NumberUtil.format(floatValue, this.format);
                } else if (this._editFormatter != null) {
                    return this._editFormatter(floatValue, this);
                } else if (this.decimalPrecision != null || this.decimalPad != null) {
                    return isc.Canvas.getFloatValueAsString(floatValue,
                        this.decimalPrecision, this.decimalPad);
                } else if (this.precision != null) {
                    return isc.Canvas.getNumberValueAsString(floatValue,
                        this.precision, "float");
                }
            }
        }
        return this.Super("mapValueToDisplay", arguments);
    },

In the branch "if (floatValue != null)", the 2 first branch has been added. In our case, we reach the second branch ('else if (this._editFormatter != null)") and our function (MeiSimpleMoney.editFormatter) is called and then we have the scripting error. Refer to the callstack I added in attachment, it'll probably easier to understand.

It seems weird that our method editFormatter is called when the line return this._editFormatter(floatValue, this); is executed.

Any idea on this?

Thanks for your help.

Attached Images
File Type: jpg callstack.jpg (103.5 KB)
Attached Files
File Type: js MeiSimpleMoney.js (5.9 KB)

Viewing all articles
Browse latest Browse all 4756

Trending Articles