Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3257

Binding TextView with Json Model

$
0
0

Hi All,

 

I am creating an sapui5 app along with Local JSON data and I am unable to fetch the value of Purchase Order Detail in TextView i.e. unable to bind them.

At the same time i am able to bind Purchase Order with the action ListItem.

 

Below is my code:

 

//JSON Model

var data = {

  "Purchase Order List" : [

      {"Purchase Order" : "001", "Purchase Order Detail":"abc"},

      {"Purchase Order" : "002", "Purchase Order Detail":"xyz"}

  ]

};

 

//code

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

oModel.setData(data);

sap.ui.getCore().setModel(oModel);

 

 

var oApp = new sap.m.App("mApp", { initialPage:"mainPage" });  

 

 

var oPage = new sap.m.Page(

  {

    id : "mainPage",

    title: "List of Purchase Orders",

    enableScrolling: false

  });

   

var oTextView = new sap.ui.commons.TextView("textView",

                                            {

  text: "{/Purchase Order Detail}"

});

     var detailPage = new sap.m.Page(

  {

    id : "detailPage",

    title: "Detail",

    enableScrolling: false,

    showNavButton : true,

    content:[oTextView],

    navButtonPress : function()

    {

    detailPage.unbindElement ();

    oApp.to("mainPage");

  },

  });  

var oList = new sap.m.List(

  { 

  id : "mainList",  

  inset : false,  

  visible : true,  

  

  }); 

    var actionListItem = new sap.m.ActionListItem("action",

{

  text : "{Purchase Order}",

  press : function(oControlEvent) {

  oApp.to("detailPage", this.getBindingContext());

  }

});

    oList.bindItems("/Purchase Order List", actionListItem);

    oPage.addContent(oList);

   

oApp.addPage(oPage); 

oApp.addPage(detailPage); 

oApp.placeAt("content"); 

   

 

Please suggest how the binding will take place between TextView and  Properties which i have created in JSON Model.

Also suggest if anything other than TextView can be used.

 

Regards,

Abhilasha


Viewing all articles
Browse latest Browse all 3257

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>