2015-12-23 24 views
-1

我有花DB一個表,暴露它作爲xsodata服務如何更新按鈕點擊表或模型

service { 
"schema"."table" as "OrderItem"; 
} 

顯示在UI5應用作爲

var Model = new sap.ui.model.json.JSONModel("../../services/myexp.xsodata/OrderItem", false); 
sap.ui.getCore().setModel(Model,'myitem'); 

var oTemplate = new sap.m.ColumnListItem({ 
     cells : [ 
      new sap.m.Text({text : "{myitem>Component}"}), 
      new sap.m.Text({text : "{myitem>Customer}"}), 
      new sap.m.Text({text: "{myitem>Required Date}"}), 
      new sap.m.Text({text : "{myitem>Status}"}) 
     ] 
    }); 

oTable.bindItems("myitem>/d/results", oTemplate); 

做工精細 enter image description here

現在在圖像中,我在頁面頁腳處添加了兩個按鈕作爲

footer: new sap.m.Bar({ 
    contentRight: [ 
     new sap.m.Button({text: "Accept",type: sap.m.ButtonType.Accept}), 
     new sap.m.Button({text: "Reject",type: sap.m.ButtonType.Reject}) 
    ] 
}) 

現在我的問題是如何更新單擊任何按鈕狀態列,說如果我按接受狀態將更改爲接受和拒絕相同。 (更新模型,我猜hana表會自動更新爲tyhe表暴露爲odata模型)

注意這張表只會有一行。

謝謝

+0

是否要更新服務器上的數據還是隻有模型中的數據? – Rayon

回答

0

你沒有得到那樣的功能與JsonModel。只有使用OdataModel,您才能獲得這種功能。

J.

+0

好吧,讓我們說我使用odata模型來代替jsonmodel,但是如何將更新功能添加到不在表格行中的按鈕,它在頁面頁腳中。 –

0

您可以從按鈕的按下事件調用一個函數:

footer: new sap.m.Bar({ 
    contentRight: [ 
      new sap.m.Button({ 
text: "Accept", 
type: sap.m.ButtonType.Accept, 
press: oController.pressAcceptButton}), 
      new sap.m.Button({ 
text: "Reject", 
type: sap.m.ButtonType.Reject}) 
     ] 
}) 

,並在控制器,這個新聞發佈會上回應:

pressAcceptButton: function(oEvent){ 
//perform transaction and refresh models 
}