Skip to Content
0

sap.m.IconTabBar binding of items

Feb 16, 2017 at 06:13 AM

123

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Mahesh Phajage Feb 16, 2017 at 12:07 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Mahesh,

Thanks you provide JSONModel. But i want to bind as ODataModel in XML view. Pls share OdataModel example.

0
Elena Makarenko
Feb 16, 2017 at 12:42 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Elena,

Thanks for your reply.

The link which you provide is not opening for me. :-(

I want to bind using oDatamodel. can you suggest some other code.

0