Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3354

Re: Dynamic views in XML. Alternative 'IF' and 'FOREACH'.

$
0
0

Hi Pradeep!

Here's example of simple dynamic view in JavaScript. Can you implement it in XML?

 

001.png

 

CONTROLLER:

ap.ui.controller("sap.ui.simple.controller.JSView", {      o_struct: {  "panels": [       {       number: 1,       expandable : true,         expanded : true,         buttons:[             {             text: "Hello!",             press: "onShowHello"             },             {             text: "Bye!",             press: "onShowBye"             }         ]       },       {       number: 2,       expandable : true,         expanded : false,         buttons:[             {             text: "1",             press: "onShow1"             },             {             text: "2",             press: "onShow2"             },             {             text: "3",             press: "onShow3"             }         ]       }  ]  },  onInit: function() {}
});

 

VIEW:

sap.ui.jsview("sap.ui.simple.view.JSView", {  getControllerName: function() {  return "sap.ui.simple.controller.JSView";  },  createContent: function(oController) {  var o_data = oController.o_struct;  var panels = [];  var buttons = [];  o_data.panels.forEach(function(panel, i){  buttons = [];  panel.buttons.forEach(function(button, j){  buttons[j] = new sap.m.Button("SimpleButton_"+i+j, {  text: button.text  });  });  panels[i] = new sap.m.Panel("SimplePanel_"+i ,{  headerText: "Panel-" + panel.number,  expandable: panel.expandable,     expanded: panel.expanded,     content: [buttons]  });  });  var oBox = new sap.m.VBox("SimpleVBox", {  items: [panels]  });  var oPage = new sap.m.Page({  title:"Simple JSView",  showNavButton:false,  content: [oBox]  });  return oPage;  }
});

If yes, then me would be very interested to see your solution!


Viewing all articles
Browse latest Browse all 3354

Trending Articles



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