Skip to Content
0

How to display database data in table in view.xml ??

Mar 04, 2017 at 09:57 AM

83

avatar image
Former Member

Hi,

How do I display my database data in my view when I click the button? I'm using SAP HANA Web-Based Development Workbench to do my project.

Below are my code:

my view name is: DishesView.view.xml

my button function:

searchbrowniesbtn: function() {


var oModel = new sap.ui.model.odata.v2.ODataModel("https://testp1942054543trial.hanatrial.ondemand.com/testing/service/Connection.xsodata",false);

var oControl;
		
var oTable = new sap.ui.table.Table("DishesView", {tableId: "tableID",visibleRowCount: 8});
						
oControl = new sap.ui.commons.TextField().bindProperty("value", "DISHESID");

oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text:"DISHESID"}),template :oControl,sortProperty :"DISHESID",filterProperty :"DISHESID",width :"125px"}));
   
oControl = new sap.ui.commons.TextField().bindProperty("value", "DISHESNAME");

oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text:"DISHESNAME"}),template :oControl,sortProperty :"DISHESNAME",filterProperty :"DISHESNAME",width :"125px"}));

oControl = new sap.ui.commons.TextField().bindProperty("value", "DISHESDESC");

oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text:"DISHESDesc"}),template :oControl,sortProperty :"DISHESDESC",filterProperty :"DISHESDESC",width :"125px"}));
   
oControl = new sap.ui.commons.TextField().bindProperty("value", "DISHESPRICE");

oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text:"DISHESPRICE"}),template :oControl,sortProperty :"DISHESPRICE",filterProperty :"DISHESPRICE",width :"125px"}));
                    
oTable.setModel(oModel);
                
oTable.bindRows("/DishesView");
//this.getView().setModel(oModel);
                
sap.m.MessageToast.show("Read Data Successfully");
},

my table name is: "testing.table::Dishes.Dishes"

my xsodata file:

service{
"testing.table::Dishes.Dishes" as "Dishes" create using "testing.procedure::CreateDishes";

"testing.table::OrderStock.OrderStock" as "OrderStock" create using "testing.procedure::CreateOrder";

"testing.table::Receiving.Receiving" as "Receiving";

"testing.table::Dishes.Dishes" as "DishesView";
}

Thank You.

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

2 Answers

avatar image
Former Member Mar 05, 2017 at 10:24 AM
0

I've go through some posts from this website and other website, and here is my code:

oModel.read("/ViewDishes",null,null,false,this.successMsg,this.errorMsg);

successMsg and errorMsg are here:

successMsg: function() {
			sap.m.MessageToast.show("Read Data Successfully");
		},


errorMsg: function() {
			sap.m.MessageToast.show("Fail to Read Data");
		}

I can get my success message, but I couldn't see any data in my view...

please help...

Thanks.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Mar 07, 2017 at 07:25 AM
0

I find out the ways to display my data already, thanks.

Share
10 |10000 characters needed characters left characters exceeded