on 03-04-2017 9:57 AM
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.
I find out the ways to display my data already, thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.