2017-04-25 6 views
1

나는 현재 UI5와 조건 라우팅을 구현하기 위해 노력하고있어 ... SAP UI5 RadioButtonGroup 구성은

내 view.xml입니다 지금 :

sap.ui.define([ 
    "sap/ui/core/mvc/Controller" 
], function(Controller) { 
    "use strict"; 

    return Controller.extend("wizard.controller.page1", { 

     _onStandardTilePress: function (oEvent) { 
      var oapp = sap.ui.getCore().byId("dcw"); 

     oapp.to("idpage2"); 
     } 
    }); 
    } 
) 

StandardTile 보증 기간을 클릭하면 현재 idpage2로 이동합니다. RadioButton은 다시 레코딩되지 않으며 조건도 없습니다.

원하는 작업 : ID가 RB1 인 RadioButton이 선택된 경우에만 idpage2로 이동하십시오. RB2가 선택되면 idpage3으로 이동하십시오.

아이디어가 있으십니까? 당신은 "_onStandardTilePress"내

답변

1

탐색 할 위치를 정의하기 전에 RadioButtons의 "selected"속성을 선택해야합니다. 통해 getSelected() 함수를 사용하여 여기에 https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.RadioButton.html#getSelected

당신이 제공 한 정보와 조각이 잘 밖으로 일

<!DOCTYPE html> 
 
<html> 
 
\t <head> 
 
\t \t <meta http-equiv='X-UA-Compatible' content='IE=edge'> 
 
\t \t <meta charset="utf-8"> 
 

 
\t \t <title>MVC with XmlView</title> 
 

 
\t \t <!-- Load UI5, select "blue crystal" theme and the "sap.m" control library --> 
 
\t \t <script id='sap-ui-bootstrap' 
 
\t \t \t src='https://sapui5.hana.ondemand.com/resources/sap-ui-core.js' 
 
\t \t \t data-sap-ui-theme='sap_belize_plus' 
 
\t \t \t data-sap-ui-libs='sap.m' 
 
\t \t \t data-sap-ui-xx-bindingSyntax='complex'></script> 
 

 

 
\t \t <!-- DEFINE RE-USE COMPONENTS - NORMALLY DONE IN SEPARATE FILES --> 
 

 
\t \t <!-- define a new (simple) View type as an XmlView 
 
\t \t - using data binding for the Button text 
 
\t \t - binding a controller method to the Button's "press" event 
 
\t \t - also mixing in some plain HTML 
 
\t \t note: typically this would be a standalone file --> 
 

 
\t \t <script id="view1" type="sapui5/xmlview"> 
 
\t \t <mvc:View xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" controllerName="my.own.controller"> 
 
      <App id="dcw"> 
 
      <pages> 
 
       <Page id="idpage1"> 
 
       <VBox class="sapUiSmallMargin"> 
 
        <RadioButtonGroup id="bgroup" columns="2" class="sapUiMediumMarginBottom"> 
 
         <buttons> 
 
          <RadioButton id="RB1" text="start with segmentation"/> 
 
          <RadioButton id="RB2" text="start with target group"/> 
 
         </buttons> 
 
        </RadioButtonGroup> 
 
       </VBox> 
 

 
       <HBox> 
 
        <items> 
 
         <StandardTile title="End-of-Warranty" infoState="None" icon="sap-icon://car-rental" press="_onStandardTilePress"/> 
 
         <StandardTile title="End-of-Leasing" infoState="None" icon="sap-icon://car-rental" press="_onStandardTilePress"/> 
 
        </items> 
 
        <layoutData/> 
 
       </HBox> 
 
       </Page> 
 
       <Page id="idpage2" showNavButton="true" navButtonPress="onNavBack"> 
 
        <ObjectHeader title="Page2 - start with segmentation"/> 
 
       </Page> 
 
       <Page id="idpage3" showNavButton="true" navButtonPress="onNavBack"> 
 
        <ObjectHeader title="Page3 - start with target group"/> 
 
       </Page> 
 
      </pages> 
 
      </App> 
 
\t \t </mvc:View> 
 
     </script> 
 

 

 
\t \t <script> 
 
\t \t \t // define a new (simple) Controller type 
 
\t \t \t sap.ui.controller("my.own.controller", { 
 
       
 
       
 
\t \t \t \t _onStandardTilePress: function (oEvent) { 
 
        var oapp = this.getView().byId("dcw"); 
 
         
 
        if(this.getView().byId("RB1").getSelected()){ 
 
         oapp.to(this.getView().byId("idpage2")); 
 
        } 
 
        else if(this.getView().byId("RB2").getSelected()){ 
 
         oapp.to(this.getView().byId("idpage3")); 
 
        } 
 
       }, 
 
       
 
       onNavBack: function(oEvent){ 
 
        oEvent.getSource().getParent().back(); 
 
       } 
 
\t \t \t }); 
 
\t 
 
\t \t \t // instantiate the View 
 
\t \t \t var myView = sap.ui.xmlview({viewContent:jQuery('#view1').html()}); // accessing the HTML inside the script tag above 
 
\t \t 
 
\t \t \t myView.placeAt('content'); 
 
\t \t </script> 
 
\t 
 
\t </head> 
 
\t <body id='content' class='sapUiBody'> 
 
\t </body> 
 
</html>

+0

을, 감사합니다! –

+0

위대한 !! 그것을 듣기 좋은! 솔루션으로 표시 할 수 있으므로 같은 문제가있는 다른 사람들을위한 솔루션을 찾는 것이 더 쉬울 것입니다. –

0

  • 경로 적절히

문제가 발생할 수 있습니다를 선택 한 라디오 버튼

  • 확인의 인스턴스를 가져옵니다 감사합니다?