我在應用程序中有兩個分段按鈕項目作爲Delivery和Collection,我想通過從前端將Delivery作爲「D」標誌和Collection作爲「C」標誌來區分兩個按鈕,以知道哪個按鈕被點擊(這兩個按鈕包含一組輸入數據的字段)。由於我是新來的自定義SAUI5應用程序,我不知道如何通過這個單獨的。專家請幫助我。 下面是我的代碼,SAPUI5分段按鈕選擇
<SegmentedButton selectedKey="small" id="idSegment">
<items>
<SegmentedButtonItem id="idSegDel" text="Delivery" key="delKey" press="handleDelivery" />
<SegmentedButtonItem id="idSegColl" text="Collection" key="colKey" press="handleCollection" enabled="true" />
</items>
</SegmentedButton>
handleCollection: function() {
this.byId("idPanelDimension").setVisible(true);
this.byId("idPanelDimension1").setVisible(true);
},
handleDelivery: function() {
this.byId("idPanelDimension").setVisible(false);
this.byId("idPanelDimension1").setVisible(false);
this.byId("idWeight").setValue("");
this.byId("idLength").setValue("");
this.byId("idBreadth").setValue("");
this.byId("idHeight").setValue("");
},
OnCreate : function(){
var oflagSeg = "D"; //this is only for D Flag but i need to set for both as if Delivery D is clicked or Collection C cliked.
var oEntry = {Flag: oflagSeg,} //Passing odata attribute
}
您還可以使用selectedKey屬性在加載視圖上設置所選按鈕的默認值。 –