javascript - 使用 JS 和 XML 更改文本控件中的 OData 值

标签 javascript xml sapui5 export-to-csv

结果最初显示在文本控件中,然后乘以从 Odata 加载并显示在输入控件中的价格和数量。目标是,在将新价格和新数量输入到输入控件后,结果应在该文本控件中自动更新。使用 _onChange() 我可以更改 OData 的属性(在本例中是价格和数量)(我已经看到更新的属性并导致调试器模块)。但是更新后的结果并没有显示在文本控件中,有人知道吗?

XML:

<t:Column>
    <Text text="Price"/>
     <t:template>
        <Input id="price" value="{Prc}" editable="true"  change="_onChange"/>
     </t:template>
</t:Column>
<t:Column>
    <Text text="Quantity"/>
     <t:template>
        <Input id="quantity" value="{Qty}" editable="true"  change="_onChange"/>
     </t:template>
</t:Column>

JS:

  _onChange: function(oEvent){
  var test = oEvent.getSource();
  var path = test.getBindingContext().getPath();
  var obj = oModel.getProperty(path);

  var stringID=test.sId;
  //determine the current control using the predefined ID
  switch(oEvent!=null){
   case stringID.match("quantity")!=null
       //read the Input of quantity  in Input control
       obj.Qty = test._$input.context.value;   
       break;
   case stringID.match("price")!=null:
       //read the input of price in Input control
       obj.Prc = test._$input.context.value;   
       break;
};
var sum = parseInt(obj.Prc) * parseInt(obj.Qty);
obj.Result =sum.toString();
}

最佳答案

如果您在模型中绑定(bind)了 RESULT,请使用它来更新模型。

关于javascript - 使用 JS 和 XML 更改文本控件中的 OData 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46040149/

相关文章:

java - Spring Boot 。映射 2 个独立的项目 Controller 而忽略一个项目

日期选择器 : How to change the focus of calendar to today's date in UI5?

javascript - 刷新无需重新加载

android - xml/linearlayout 无法在设备上正确显示

javascript - jQuery 在 div 和切换类之外找到下一个类

iphone - 使用 NSString 格式的 XML 初始化 NSXMLParser

sapui5 - 使用 ODataModel 与 JSONModel 相比有什么好处?

javascript - 在 View 中查看 Controller 的模型数据 [sap ui5]

javascript - 在 Visual Studio 2019 中将 TS 编译为 JS 时如何从 JS 文件中删除导入指令

javascript - 仅在 iPad 上禁用 javascript 代码