我是SAPUI5的新手,想要创建一个包含几个基于SAPUI5的CheckBox的页面。此时我有以下代码来创建CheckBoxes:
function chosevalues(){
re_items = [];
var items = [];
var text = ["1070","1071","1072","1073","1074","1075","1076"];
for (var i = 0; i < text.length; i++) {
alert("in for with i= " + i);
var box = new sap.ui.commons.CheckBox({
text : text[i],
tooltip : 'Value checkbox',
checked : false,
change : function() {
if(oCB.getChecked()){
alert(this.getText());
re_items.push(this.getText());
}else{
alert('NO');
}
}
});
items.push(box);
}
page4.addContent(items);
app.to("page4");
}
现在我将数组放在页面内容上,但文本和方框非常小。 我尝试使用sap.ui.table.Table和sap.m.List。没有任何效果。 它应该是这样的:SAPUI5 Explored - CheckBox 但我发现没有办法在我的javascript代码中包含mvc-view。
一方面,我可以用javascript编程来创建像示例一样的CheckBoxes,另一方面我可以尝试包含mvc-view。 问题是,我不知道两者。
答案 0 :(得分:1)
in SAPUI5 there are 2 major libraries - sap.ui.commons (for desktop only) and sap.m (for both desktop and mobile).
You have to decide which library suits most to your needs and go for it.
What you were trying to achieve (large check boxes) is possible only when using sap.m library.
Here is a small examle code based on your function:
var text = ["1070","1071","1072","1073","1074","1075","1076"];
var oVBox = new sap.m.VBox();
for (var i = 0; i < text.length; i++) {
oVBox.addItem(new sap.m.CheckBox({text:text[i]}));
}
And here is a demonstration: LINK