Skip to Content

sap.m.IconTabBar binding of items

Hi,

I tried to display Icontab filters in IconTabBar dynamically from Odata with inputs.Please verify and share your suggetions to bind/set data to the IconTabBar.

Below pseudo code I used

XML View :

<IconTabBar id="idIconTabBarcib" select="chgCatgTabSelect" >

<items><IconTabFilter key="{ZCatg" text="{ZText}">

</IconTabFilter></items> <!-- sap.m.IconTab -->

<content></content> <!-- sap.ui.core.Control --> </IconTabBar>

Controller :

var oModel = this.getView().getModel();

var sPath = "/PENDING_DETAILS_EMP_INFOSet(ImPernr='4039',ImWiid='000001598333')";

if(oModel){

var oContext = new sap.ui.model.Context(oModel,sPath);

}

if(oContext){

var oController = this; oModel.read(sPath,{

success: function(oData,oResponse){ oController.getView().byId("idIconTabBarcib").bindAggregation(oData);

},

error: function(oResponse){ //alert("Error"); } }) }

Please let me know what should be syntax to pass above filter values and bind it to IconTab Filter items

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Feb 16, 2017 at 12:07 PM

    Hello,

    You can use below code:

    var iconTabBarId = this.getView().byId("iconTabBarIdName");

    var template = sap.m.IconTabFilter({

    key: "{ZCatg}"

    text: "{ZText}"

    });

    var oModel = new sap.ui.model.json.JSONModel();

    oModel.setData({ modelData: oData.results }); // Check whether you are getting data in oData or not

    iconTabBarId.setModel(oModel);

    iconTabBarId.bindAggregation("items", "/modelData", template);

    after that you will get output.

    // in you code there is missing "}" see below:

    <IconTabFilter key="{ZCatg}" text="{ZText}">

    Hope this will help you!!!!

    Regards,

    Mahesh Phajage

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 16, 2017 at 12:42 PM

    Hi Vinothkumar,

    you can find here a working example of dynamical binding of IconTabBar items:
    http://veui5infra.dhcp.wdf.sap.corp:8080/snippix/#81410

    It is based on JSONModel, but you can easily adapt it for ODataModel.

    Best regards,
    Elena

    Add comment
    10|10000 characters needed characters exceeded