我的 REST 服务向我发送了大量数据。每个属性都包含value
and a help
- 包含字段属性的详细描述的属性。
好的,我在 JSONModel 中有数据(具有值和帮助的属性列表),并且我使用数据绑定XML https://openui5.hana.ondemand.com/#docs/guide/91f0f3cd6f4d1014b6dd926db0e91070.html https://openui5.hana.ondemand.com/#docs/guide/91f0f3cd6f4d1014b6dd926db0e91070.html映射数据value
在表格和表格中。
现在我想以某种方式展示help
每个属性的消息。
我的想法是展示一个消息对话框 https://openui5.hana.ondemand.com/explored.html#/entity/sap.m.Dialog/samples当用户双击Label https://openui5.hana.ondemand.com/docs/api/symbols/sap.m.Label.html或在Text https://openui5.hana.ondemand.com/docs/api/symbols/sap.m.Text.html表中的列标题
标签和文本都有附加浏览器事件 https://openui5.hana.ondemand.com/docs/api/symbols/sap.ui.core.Control.html#attachBrowserEvent方法但是我不知道如何使用该函数附加事件仅在 XML 视图中写入
我想要这样的东西:
在 XML 视图中:
<Label text="Language"
attachBrowserEvent:"function("click",showMessageHelp({model>/language/help}))">
<Input value="{model>/language/value}"/>
在控制器中:
showMessageHelp:function(sMessage){
//show message dialog with sMessage
...........
}
您可以使用以下方法实现此目的渲染后方法。
在 XML 中包含 CustomData:
<Label id="label" text="Language">
<customData>
<core:CustomData key="type" value="{/language/help}" />
</customData>
</Label>
然后在控制器中使用这个自定义数据:
onAfterRendering: function () {
var showValueHelp = function () {
var text = this.getCustomData()[0].getValue();
sap.m.MessageToast.show(text);
event.preventDefault();
event.stopPropagation();
return false;
};
this.byId("label").attachBrowserEvent("click", showValueHelp);
}
JS 小提琴在这里 http://jsfiddle.net/d6s2up8k/
PS:我不确定这对您来说是否可行。
这是我目前能想到的最好的办法。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)