我的应用程序中有两个分段按钮项目作为交付和收集,我想通过传递交付来区分两个按钮" D"旗帜和收藏品作为" C"从前端标记,以了解单击了哪个按钮(这两个按钮包含一组输入数据的字段)。由于我是Custom SAUI5应用程序的新手,我不知道如何将其作为单独传递。专家请帮帮我。 以下是我的代码,
<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
}
答案 0 :(得分:0)
您不应为每个按钮单独使用按事件,因为它是分段按钮的聚合控件。使用&#34;选择&#34;分段按钮控件中的事件,并获取所选按钮的键。请通过以下链接,我已编写代码。
http://veui5infra.dhcp.wdf.sap.corp:8080/snippix/snippets/34075
答案 1 :(得分:0)
感谢您的想法,我已经完成并完美运行,下面是我的代码。
var oflagSeg = "";
var mainseg = sap.ui.getCore().byId("idRetDel1--idSegment").getSelectedKey();
if(mainseg == "keyDel"){
oflagSeg = "D";
}else if(mainseg == "keyCol"){
oflagSeg = "C";
}