sap.m.Dialog Fragment中的SAPUI5 NavContainer

时间:2014-09-11 11:14:25

标签: sapui5

是否有可能在NavContainer内使用sap.m.Dialog fragment。在PopOver中可以完成它但是在使用Dialog进行尝试时,在对话框中不会呈现任何内容。

以下是代码:

<core:FragmentDefinition xmlns:core="sap.ui.core"
  xmlns:layout="sap.ui.layout" xmlns="sap.m">
    <Dialog title="Customer Search" type="Message">

    <NavContainer id="navCon">
    <Page id="master" title="Search ">
         <Label text="Customer Name"></Label>
         <Input></Input>

         <Label text="Payer Code"></Label>
         <Input></Input>

        <Label text="Customer City"></Label>
        <Input></Input>

       <Label text="Customer Postal Code"></Label>
       <Input></Input>

       <Label text="SBU" />
       <layout:ResponsiveFlowLayout>
        <RadioButton groupName="supplierCaused" text="Yes" />
        <RadioButton groupName="supplierCaused" text="No" />
        <RadioButton groupName="supplierCaused" text="No" />
       </layout:ResponsiveFlowLayout>

      <Label text="CBT"></Label>
      <Select id="searchCBT" width="100%"></Select>

      <Label text="Region" />
      <layout:ResponsiveFlowLayout>
      <RadioButton groupName="hisTransaction" text="Yes" />
      <RadioButton groupName="hisTransaction" text="No" />
      <RadioButton groupName="hisTransaction" text="No" />
      </layout:ResponsiveFlowLayout>
  </Page>

  <!--
  <Page id="detail" showNavButton="true" navButtonPress="onNavBack"
  title="Product">

     <Label text="Search Results" />

  </Page> -->
  </NavContainer>

   <beginButton>
   <Button text="Random" press="onDialogClose" />
   </beginButton>
   </Dialog>
</core:FragmentDefinition>

1 个答案:

答案 0 :(得分:1)

通过纯粹的javascript来回答你会容易得多。因为以任何方式你需要在这个对话框中附加一个打开的处理程序吗?分离代码会使这个相当简单的例子变得非常复杂。那样的东西会在简单的脚本标签中工作吗?

    var btn = new sap.m.Button({text:'Open Dialog', press: function(){oDialog.open();}});

    var oDialog = new sap.m.Dialog({
        showHeader : false,
        stretch: sap.ui.Device.system.phone ? true : false,

        beginButton : new sap.m.Button({
            text : 'OK',
            press : function() {
                oDialog.close();
            }
        }),         
        contentHeight : "500px"
    });

    var oNavContainer = new sap.m.NavContainer();
    var oPage = new sap.m.Page({
        enableScrolling : true,
        title : 'Test Page',
        subHeader : new sap.m.Bar({
            contentMiddle : new sap.m.Button({text:'SubHeader Button'})
        }),
        content : [  new sap.m.Button({text:'Content Button'}) ]
    });     
    oNavContainer.addPage(oPage); 
    oNavContainer.setInitialPage(oPage);
    oDialog.addContent(oNavContainer);

    btn.placeAt('content');
</script>

你只需要一个id =&#34;内容&#34;的div项目。它应该工作:))