css - 如何在 sapui5 中设置组合框下拉列表的高度?
问题描述
我需要在 sapui5 的组合框中为下拉列表设置最大高度。我已尝试使用以下代码。
#comboBox1-popup.sapMPopover {
max-height: 400px;
}
#comboBox1.sapMPopoverScroll {
max-height: 400px !important;
}
通过 css 我无法为项目中的特定组合框设置高度。当我尝试“sapMPopover”时,它会改变我整个项目中所有组合框的高度。我想为特定的组合框设置最大高度。提前致谢。
解决方案
因为现在有 max-height 的直接属性或从 xml 访问弹出框。您需要等到弹出列表初始化后才能从 ComboBox 获取它并向其添加自定义类。
在页面控制器中
onAfterRendering: function(){
this.exec(this);
},
exec: function(self){
var oCombo = self.getView().byId("MyComboBox"),
oPopOver = oCombo.getList();
if(oPopOver !== null
&& oPopOver !== undefined){
oPopOver.addStyleClass("test");
}else{
setTimeout(self.exec, 1, self);
}
}
在 css 文件中,您现在可以编写
.test {max-height: 100px !important;}
推荐阅读
- string - 文件路径中的字符串命令
- javascript - 使用 pagination.js 插件添加过滤器类别
- gmail - GMAIL 插件之间的通信
- sql - 在 Postgres 中创建触发器,请求 avg()
- python - 根据 Pandas、Python 中的其他 2 列值添加新列值
- javascript - D3.js 如何创建这种缩放行为?
- gitlab - Gitlab合并请求批准规则适用于非目标分支
- java - Android - 刷新 ListView 恢复正常
- python - function() 接受 1 个位置参数,但给出了 2 个
- html - 在模态中选择汽车图像上的位置。应该分成6个div