sapui5 - SAP UI5 BlockLayout - 如何设置可点击块?
问题描述
我最近开始学习 SAP UI5 并很快陷入困境。我的登录页面是围绕BlockLayout 控件构建的,该控件包含多个具有各种类别的块。这些块中的每一个都应该是可点击的——在新闻事件之后,用户被重定向到具有更多数据的子页面。
在 Fiori 设计指南中,我在 BlockLayout 部分找到了此信息
也可以让可点击的块具有自己的悬停和按下状态。
这正是我所需要的,但是,我没有找到更详细的解释。有人可以建议我吗?如何在 BlockLayout 控件中设置这些可点击的块?我应该使用 Press 事件扩展控件还是有更直接的方法?
谢谢
解决方案
好吧,已经 3 年了,但我有解决方案:我们可以使用以下方法将浏览器事件附加到确定的元素
oElement.attachBrowserEvent("click", function() {
alert()
})
但是我制作了这段代码来获取一个数组,其中包含所有元素,其中包括在其 id 中确定的字符串,这个 id 由 sapUi5 创建。
var oElements = this.getView().findElements(true); // Get all elements from the view
var array = [];
// search trhoug the elements of the view a element that the ID includes "cell" (from the original ID: __celln)
oElements.forEach(oElement => {
if (oElement.sId.includes("cell")) {
array.push(oElement); // And pushes them into the array
}
})
// go trhoug all elements of the array attaching the click event
array.forEach(cell => {
cell.attachBrowserEvent("click", function() {
alert()
})
})
推荐阅读
- r - 使用 system() 打开带有 URL 参数的本地 index.html
- python - 如何将存储为数组的 Dataframe 值转换为列表
- python - AttributeError:模块“ocrmypdf”没有属性“ocr”
- javascript - div 内容的更改不会反映在浏览器中
- python - Tk getcoords 返回空列表
- javascript - 如何从用户选择的选项绑定到 Angular 表单
- reactjs - 如何在反应中映射嵌套数组
- javascript - 如何在数组列表中对具有相同名称的元素进行分组?
- python - 如何获取 seaborn distplot 中分布峰值 y 值的 X 轴值?
- html - 如何从 Angular 向 node.js 发送一个数字