[英]SAPUI5 formatter function not working properly inside Input Control
我需要根据一个条件突出显示表格的一些单元格边框 colors 并用一些负值预填充它。 然后我需要保存/发布这个值以进一步进行。
查看.xml
<t:Column width="100px">
<Label text="ActualQty"/>
<t:template>
<Input id="idInput" value="{ parts: [ {path: 'viewData>ACT_QTY'}, {path: 'viewData>MTART'} ], formatter: '._formatter.defaultInput' }">
<customData>
<core:CustomData key="colorclass" value="{path: 'viewData>MTART', formatter: '._formatter.formatCell'}" writeToDom="true"/>
</customData>
</Input>
</t:template>
</t:Column>
格式化程序.js
formatCell: function (iValue) {
try {
iValue.toString();
} catch (err) {
iValue = "foo";
}
return iValue.toString();
},
defaultInput: function (iValue, iValue1) {
if (iValue !== 0 && iValue1 === "HALB") {
iValue = "-1";
return iValue;
} else {
return iValue;
}
}
样式.css
div[data-colorclass="HALB"] {
border: 4px solid #fdf6b1 !important;
}
突出显示并出现默认值。 但是在controller里面,输入值不来。
如果我删除零件并将单个输入参数传递给格式化程序 function,它的工作原理。 但是我需要这两个值来构建我的逻辑。
现在我使用复合绑定将绑定设置为双向。
查看.xml
<Input id="idInput" value="{ parts: [ {path: 'viewData>ACT_QTY'}, {path: 'viewData>MTART'} ], type: '._Compound', formatter: '._formatter.defaultInput' }">
复合.js
sap.ui.define([ "sap/ui/model/CompositeType", "dismantling/bom/integration/model/type/Compound" ], CompositeType => CompositeType.extend('Compound', { constructor: function () { CompositeType.apply(this, arguments); this.bParseWithValues = true; // make 'parts' available in parseValue }, formatValue: iValue => iValue, parseValue: bValue => bValue, validateValue: vValue => { /*validate...*/ }, }));
在 controller 文件中,我将复合类型传递为“_Compound”。 我在控制台中没有收到任何错误。
尽管如此,我还是无法在 controller 中获取格式化程序传递的值。
请指导。
您的格式化程序是正确的。 确保在绑定路径下可以实际访问这些值,并且视图可以访问格式化程序。 如果这两件事都得到保证,你的 function 就可以正常工作了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.