设置在IconTabBar中选择的特定选项卡

时间:2016-05-06 11:47:10

标签: sapui5

我的图标标签条形码:

new sap.m.IconTabBar("iconTabBar", {
    expandable: false,
    expanded: false,
    items: [
        new sap.m.IconTabFilter({
            text: "Orders",
            key: "All",
            icon: "sap-icon://home"
        }),
        new sap.m.IconTabFilter("iconTabFilter6", {
            text: "Open",
            key: "Open",
            icon: "sap-icon://home"
        }),
        new sap.m.IconTabFilter({
            text: "In Process",
            key: "InProcess",
            icon: "sap-icon://home"
        })
    ]
});

我放expanded: false所以没有选择标签。现在如何选择一个特定的选项卡?说第二个(Open)。

我尝试了什么:

var open = iconTabBar.getItems()[1]; // retruning 2nd Item
open.setExpanded(true); // error: getItems(...)[1].setExpanded is not a function

2 个答案:

答案 0 :(得分:2)

在您的代码示例中,您将expanded属性设置为IconTabFilter,而不是IconTabBar

尝试使用所需setSelectedKey的密钥在IconTabBar上设置IconTabFilter

答案 1 :(得分:0)

new sap.m.IconTabBar("iconTabBar", {
    selectedKey = "Open",
    items: [
        new sap.m.IconTabFilter({
            text: "Orders",
            key: "All",
            icon: "sap-icon://home"
        }),
        new sap.m.IconTabFilter("iconTabFilter6", {
            text: "Open",
            key: "Open",
            icon: "sap-icon://home"
        }),
        new sap.m.IconTabFilter({
            text: "In Process",
            key: "InProcess",
            icon: "sap-icon://home"
        })
    ]
});