更改 CurrencyTextBox 货币的技巧是什么

What is the trick to changing currency of CurrencyTextBox

我有一个 CurrencyTextBox,我在其中将货币设置为默认货币。用户可以通过在同一表单上的货币下拉列表中进行选择来更改它。我以为我可以动态更改文本框上的货币属性,但没有任何反应。符号不会改变。有什么技巧可以使这项工作成功吗?我看过相关的帖子必须销毁并重新创建小部件。好像还有更好的办法?

我想即时将 unitCostId 小部件的货币设置为用户选择的货币。结果将是货币符号将更改以匹配新选择的货币。

  new CurrencyTextBox ({
        id: "unitCostId",
        name: "price",  
        currency: "USD",
        required: true,
        value: "",
        placeHolder: "Enter Price"
    }, "unitCostNode");
----------------------------------------------------
  new Select({
        id: "currencyOptionsId",
        name: "currency_code",
        value: "USD",
        options: currencyOptions,
        required: true,
        onChange: function(val) {
           var currency_id = this.get("value");
           registry.byId("unitCostId").set("currency",this.get("value");
        // registry.byId("unitCostId").reset();
         }
        }, "currencyNode");

如有任何帮助,我们将不胜感激!

不幸的是,currency 属性 没有 setter 逻辑,并且被记录为常量。但是,由于底层代码的工作方式,您仍然可以通过 constraints 设置来更改它:

registry.byId("unitCostId").set("constraints", { currency: this.get("value") });