Search This Blog

Monday, May 22

SAPUI5 Table Binding with Data Coming from Backend

The Data that need to be displayed on SAPUI5 Table control resides of a backend system. The Data is fetched via oData services read call and rendered in table UI Control in below fashion


   
oModelECST_FETCH.read(url5,null, null, true, function(oData, oResponse){ debugger;
 oInvoices = new sap.ui.model.json.JSONModel({ "Invoices" : oData.results }); oInvoices.iSizeLimit = 100000;    
var tab =this.getView().byId("invoicestable"); // invoicestable is the ID of Table UI Control
   
tab.setModel(oInvoices);
var i=0;
tab.bindAggregation("items", {

path: "/Invoices",
template: new sap.m.ColumnListItem({
cells: [
     //
 new  sap.m.CheckBox({visible:invoicesThat.strtoBool(oData.results[tableIndex1].Count)}).setSelected(true),
       new  sap.m.CheckBox("cbinv",{visible:"{Count}", selected:"{Sel}"}),
     
       new  sap.ui.commons.TextView({ text: "{InvNo}", design:"Standard", semanticColor:"Default"}),
       new  sap.ui.commons.TextView({ text: "{InvDate}", design:"Standard", semanticColor:"Default"}),
       new  sap.ui.commons.TextView({ text: "{Tin}" , design:"Standard", semanticColor:"{semCol}"}),
//        new  sap.ui.commons.TextView({ text: "{FormNum}", design:"Standard", semanticColor:"Default"}),
       new  sap.ui.commons.TextView({ text:"{TypeOfTx}",design:"Standard",semanticColor:"Default"}),
       new  sap.ui.commons.TextView({ text: "{TaxableGoodsVal}", design:"Standard", semanticColor:"Default"}),
       new  sap.ui.commons.TextView({ text: "{AmtTaxVal}", design:"Standard", semanticColor:"Default"}),
     
       new  sap.ui.commons.TextView({ text: "{InclTaxVal}", design:"Standard", semanticColor:"Default", visible:inctaxval}),
       new  sap.ui.commons.TextView({ text: "{LabourChrgesVal}", design:"Standard", semanticColor:"Default",visible:labchargval}),
     
       new  sap.ui.commons.TextView({ text: "{OtherChrgesVal}", design:"Standard", semanticColor:"Default"}),
       //new  sap.ui.commons.TextView({ text: "{LabourChrgesVal}", design:"Standard", semanticColor:"Default"}),
       new  sap.ui.commons.TextView({ text: "{GrossTotalVal}", design:"Standard", semanticColor:"Default"}),

       ]
})
});

   },function(err){
     debugger;
   });
 

Access UI Control and Its Children at Runtime to Modify Properties | UI5

Based on user actions/output of user action, sometimes, other UI control's properties change. This behavior can be achieved by accessing UI controls mAggregation node at run time and setting desired values in UI control properties. Example of modifying 'enabled' property of a button which resides within a List's Custom list Items at place number 2. First UI control is a label, Second is the Button whose property is required to be modified


Get Currently Logged in User in SAPUI5 application

Some times to your oData calls, you want to send logged in user as one of the attributes to the call. This is how you can obtain currently logged in user within SAPUI5 application.

var y = "/sap/bc/ui2/start_up";
       var xmlHttp = null;
       xmlHttp = new XMLHttpRequest();
       xmlHttp.onreadystatechange = function() {
       if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
          var oUserData = JSON.parse(xmlHttp.responseText);
             oLoggedinID = oUserData.id;
          }
       };
       xmlHttp.open( "GET", y, false );
       xmlHttp.send(null);

 oLoggedinID will contain the login id of the person who has logged on.

thank you !
Mohammed Bohra
+91 8898030972

UI5 screen not launching from MII Navigation menu

​hi Aravinth,
When you run the application from MII navigation menu, perform a network trace to see which call is failing. Based on that further analysis can be done. Let me know if you can share your screen using AnyDesk software to enable me debug this further. 
thank you !
Mohammed
+91 8898030972