kuljit k
kuljit k

Reputation: 291

Set specific tab as selected in IconTabBar

My Icon Tab Bar code:

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"
        })
    ]
});

I put expanded: false so no tab is selected. Now how to make one specific tab selected? Say the 2nd one (Open).

What I tried:

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

Upvotes: 2

Views: 9803

Answers (2)

user3796458
user3796458

Reputation: 11

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"
        })
    ]
});

Upvotes: 0

Qualiture
Qualiture

Reputation: 4920

In your code example, you are setting the expanded property to the IconTabFilter, and not the IconTabBar.

Try setting setSelectedKey on the IconTabBar with the key of the desired IconTabFilter instead

Upvotes: 2

Related Questions