TextArea UI5获取值并设置模型

问题描述 投票:0回答:1

我想知道如何获取TextArea(Sap UI5)的内容,将其保存在变量中,将其设置为模型,然后在另一个视图中将变量设置为另一个TextArea。我已经编码了一些示例,但是可以工作,但不能在TextArea上工作。可以帮个忙。

这里:是示例代码:

//Create a Model:
//This is in the Component.js in the onInit function:

this.setModel(new sap.ui.model.json.JSONModel(), "TransportModel");

// The id in the XML of the Input Box is mat_serial
// This is to get the Value of Input Box
// This Part is in The Controller of the View where the value is getted

var serial = sap.ui.getCore().byId(this.createId("mat_serial")).getValue();

// Here i put the Value what i get from the Inputbox to the Model:

this.getView().getModel("TransportModel").setProperty("/", {

            "Serial" : serial

        });


// In the last step i set the Text from a different View (also XML and Input Box)
// with the Value of the Model Element

<Text text="{TransportModel>/Serial}" width="auto" maxLines="1" />

**This Works pretty good!**

但是如何处理Textarea?任何人都可以基于此模型提供帮助吗?我想从第一个TextArea使用的值也应该在另一个视图的TextArea上。

我希望这个社区中的每个人以及其他所有人在这个困难的时期里一切顺利。上帝保佑你!

view sap sap-fiori uitextarea
1个回答
0
投票

如何使用本地json模型:

  1. 创建

      initItemViewModel: function () {
                    return new JSONModel({
                        Serial: ""
                    });
                }
    
        this._oViewModel = this.initItemViewModel();
        this.setModel(this._oViewModel, "TransportModel");
    
    1. 正在使用

      this.getView()。getModel(“ TransportModel”)。setProperty(“ / Serial”,serial);

      <Text text="{TransportModel>/Serial}" width="auto" maxLines="1"/>
      
© www.soinside.com 2019 - 2024. All rights reserved.