所以我的代码中有一些分段按钮,它们会自动被检查为第一个。无论如何都没有检查过。我认为它可能像setselectedbutton但我不确定。
var oBt1 = new sap.m.SegmentedButtonItem({text :"yes",width : "auto"});
var oBt2 = new sap.m.SegmentedButtonItem({text :"no",width : "auto"});
var oBt3 = new sap.m.SegmentedButtonItem({text :"yes",width : "auto"});
var oBt4 = new sap.m.SegmentedButtonItem({text :"no",width : "auto"});
var oBt5 = new sap.m.SegmentedButtonItem({text :"yes",width : "auto"});
var oBt6 = new sap.m.SegmentedButtonItem({text :"no",width : "auto"});
var oSelectDD = new sap.m.SegmentedButton({items : [oBt1, oBt2]})
.addStyleClass("bgDarkBack-SB");
oSelectDD.setSelectedButton(false);
var oSelectDD2 = new sap.m.SegmentedButton({items : [oBt3, oBt4]})
.addStyleClass("bgDarkBack-SB");
var oSelectDD3 = new sap.m.SegmentedButton({items : [oBt5, oBt6]})
.addStyleClass("bgDarkBack-SB");
答案 0 :(得分:0)
创建一个从未显示的测试按钮,并将其设置为默认选择。
var oBt1 = new sap.m.SegmentedButtonItem({text :"yes",width : "auto"});
var oBt2 = new sap.m.SegmentedButtonItem({text :"no",width : "auto"});
var oBt3 = new sap.m.SegmentedButtonItem({text :"yes",width : "auto"});
var oBt4 = new sap.m.SegmentedButtonItem({text :"no",width : "auto"});
var oBt5 = new sap.m.SegmentedButtonItem({text :"yes",width : "auto"});
var oBt6 = new sap.m.SegmentedButtonItem({text :"no",width : "auto"});
var oBt7 = new sap.m.SegmentedButtonItem({text :"test",width : "auto"});
var oSelectDD = new sap.m.SegmentedButton({items : [oBt1, oBt2]})
.addStyleClass("bgDarkBack-SB");
oSelectDD.setSelectedButton(oBt7);
var oSelectDD2 = new sap.m.SegmentedButton({items : [oBt3, oBt4]})
.addStyleClass("bgDarkBack-SB");
oSelectDD2.setSelectedButton(oBt7);
var oSelectDD3 = new sap.m.SegmentedButton({items : [oBt5, oBt6]})
.addStyleClass("bgDarkBack-SB");
oSelectDD3.setSelectedButton(oBt7);