使用 XML-View 将浏览器事件附加到控件 [英] Attach browser event to a control using XML-View
问题描述
我的 REST 服务向我发送了大量数据.每个属性都包含 value
和一个 help
属性,其中包含对字段属性的详细描述.
My REST service send me a lot of data. Every property contains the value
and a help
-attribute that contains a long description of the field property.
好的,我在 JSONModel 中有数据(带有值和帮助的属性列表),我使用数据绑定 XML https://openui5.hana.ondemand.com/#docs/guide/91f0f3cd6f4d1014b6dd926db0e91070 映射<数据值代码> 在表格和表格中.现在我想以某种方式为每个属性显示 help
消息.
Ok, I have data (a list of property with value and help) in a JSONModel and I use data-binding XML https://openui5.hana.ondemand.com/#docs/guide/91f0f3cd6f4d1014b6dd926db0e91070.html to map data value
in forms and tables.
Now I want show somehow help
message for each property.
我的想法是显示一个消息对话框 当用户双击 标签 或列的Text表头
My idea is show a message dialog when the user double-click on the Label or on the Text of the column header in a table
标签和文本都有 attachBrowserEvent 方法但我不知道如何使用该函数附加事件仅在 XML 视图中写入
Both Label and Text have attachBrowserEvent method but I don't know how use the function to attach the event wrinting only in the XML-views
我想要这样的东西:
在 XML 视图中:
<Label text="Language"
attachBrowserEvent:"function("click",showMessageHelp({model>/language/help}))">
<Input value="{model>/language/value}"/>
在控制器中:
showMessageHelp:function(sMessage){
//show message dialog with sMessage
...........
}
推荐答案
可以为每个标签附加浏览器事件,但我找不到不重复每个标签 ID 的方法.
Attach a browser event for each label is possible but I can't find a way to do it without repeat each label id.
我找到了一个替代解决方案:我的数据显示在表格和表格中.我在每个表单的右侧添加了一对 label: value 带有帮助信息的 Text 元素:
I have found an alternative solution: my data are shown in forms and tables. I have added on the right of each form couple of label: value a Text element with the help info:
<Label text="Field duck"/>
<Text text="{model>/elements/mainFields1/duck/value}"/>
<Text text="{model>/elements/mainFields1/duck/ATTR/help/description}" visible="{ui>/bShowHelp}" />
在表格中,我将每列标题分为两组:页眉和页脚;在页脚中我放置了帮助信息:
In tables I have divided each column title in two group: header and footer; in the footer I have placed the help info:
<Column>
<header>
<Text text="Name"/>
</header>
<footer>
<Text text="{model>/elements/airports/templateNewRow/name/ATTR/help/description}" visible="{ui>/bShowHelp}"/>
</footer>
</Column>
我更改了 bShowHelp
显示和隐藏所有帮助信息的值
I change the value of bShowHelp
showing and hiding all help infos
这篇关于使用 XML-View 将浏览器事件附加到控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!