Skip to Content
avatar image
Former Member

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

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

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

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 07, 2017 at 07:25 AM

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

    Add comment
    10|10000 characters needed characters exceeded