How to retrieve table values in SAP UI5 Fiori

Define your table at view.js

 

var oTable = new sap.m.Table(“oTable”,{

growingScrollToLoad : true,

mode : sap.m.ListMode.MultiSelect,

width : “700px”,

columns : [

new sap.m.Column ({

   header : new sap.m.Label({

         text : “Col1”,

         design : “Bold”

   }),

   width : ‘150%’,

          resizable : false,

          flexible : false,

}),

new sap.m.Column ({

   header : new sap.m.Label({

         text : “Col2”,

         design : “Bold”

   }),

   width : ‘75%’,

          resizable : false,

          flexible : false,

}),

new sap.m.Column ({

   header : new sap.m.Label({

         text : “Col3”,

         design : “Bold”

   }),

   width : ‘175%’,

          resizable : false,

          flexible : false,

}),],

 

Retrieve data at controller.js

 

var oTable = sap.ui.getCore().byId(“oTable”);

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

oModel.attachRequestSent(function(){});

oModel.attachRequestCompleted(function(){});

var oParameters = {

“method” : “GET_TABLE_VALUES “};

oModel.loadData(“/zappname/”,oParameters);

oModel.setSizeLimit(999999);

oTable.setModel(oModel);

oTable.bindItems(“/”,

new sap.m.ColumnListItem({

type : sap.m.ListType.Navigation,

cells :

[

new sap.m.Input({

    value: ‘{val1}’}),

new sap.m.Label({

    text: “{val2}”,

    wrapping : false}),

new sap.m.Label({

    text: “{val3}”,

    wrapping : false}),

]

}));

 

Way to call SAP Fiori

Job:

Calls SAP service named ‘zanilfiori’

Calls method “CHECK_USER_AND_PASSWORD”

in SAP service named ‘zanilfiori’ with input parameters:

Username = username

Password = password.

Then gets a return named data.

// Defining Parameters

var oParameters = {

“method” : “CHECK_USER_AND_PASSWORD”,

“username” :  ‘username’,

“password” :  ‘password’

};

oBusyDialog.open();

$.ajax({

url : “/zanilfiori/” ,

contentType : “application/json”,

dataType : “json” ,

data : oParameters ,

success : function(data, textStatus ,jqXHR)

{

console.log(data);

oBusyDialog.close();

if(data.type == ‘S’)

{

sap.m.MessageToast.show(data.message ,{

at : “center center”

});

}

}

});