输入事件suggestionItemSelected不激活

时间:2015-03-11 15:02:15

标签: sapui5

我有一个输入组件:

<Input
   value=""
   showSuggestion="true"
   showValueHelp="true"
   valueHelpOnly="true"
   valueHelpRequest="handleValueLocalHelp"
   suggestionItemSelected="onLiveChangeSimple"
/>

这是我的功能:

onLiveChangeSimple: function (oEvent) {
        console.log("OK!")
    },

当我登录输入时,我会在帮助说明书中显示建议项目;然后我选择一个项目并且输入值正确更改onLiveChangeSimple不要点火!为什么呢?

如果我在此模式下修改输入:

<Input
       value=""
       liveChange="onLiveChangeSimple"
    />

onLiveChangeSimple开始...

在“帮助”对话框中登录项目时触发的事件是什么?

2 个答案:

答案 0 :(得分:0)

它应该很好......但是我注意到你没有在suggestionItems控件中指定聚合Input,你是否以不同的方式管理事物?

<Input
  id="productInput"
  type="Text"
  placeholder="Enter Name ..."
  showSuggestion="true"
  suggestionItems="{/}"
  suggestionItemSelected="suggestionItemSelected">
    <suggestionItems>
      <core:Item text="{name}" />
    </suggestionItems>
</Input>

请参阅以下有关如何触发suggestionItemSelected事件的工作示例:

jQuery.sap.require("sap.m.MessageBox");

sap.ui.controller("view1.initial", {
  onInit : function(oEvent) {
    var aData = [
      {name: "Dente, Al", userid: "/c01/b2/u3/u44"},
      {name: "Friese, Andy", userid: "/a01ss/a2/u3/u44"},
      {name: "Mann, Anita", userid: "/U013333/u2/u3/u44"},
      {name: "Schutt, Doris", userid: "/U01/u2/u3/u44"},
      {name: "Open, Doris", userid: "/U01/u2/u3/u44"},
      {name: "Dewit, Kenya", userid: "/U01/u2/u3/u44"},
      {name: "Zar, Lou", userid: "/U01/bu2/u3/u44"},
      {name: "Burr, Tim", userid: "U08"},
      {name: "Hughes, Tish", userid: "U09"},
      {name: "Town, Mo", userid: "U10"},
      {name: "Case, Justin", userid: "U11"},
      {name: "Time, Justin", userid: "U12"},
      {name: "Barr, Sandy", userid: "U13"},
      {name: "Poole, Gene", userid: "U14"},
      {name: "Ander, Corey", userid: "U15"},
      {name: "Early, Brighton", userid: "U16"},
      {name: "Noring, Constance", userid: "U17"},
      {name: "O'Lantern, Jack", userid: "U18"},
      {name: "Tress, Matt", userid: "U19"},
      {name: "Turner, Paige", userid: "U20"}
    ];

    var oModel = new sap.ui.model.json.JSONModel();
    oModel.setData(aData);
    this.getView().setModel(oModel);
  },

  suggestionItemSelected: function(oEvent) {
    sap.m.MessageBox.show("Selected " + oEvent.getParameter("selectedItem").getBindingContext().getObject().name);
  }
});

var oView = sap.ui.xmlview({
  viewContent: jQuery("#view1").html()
});

oView.placeAt("uiArea");
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>

    <title>SAPUI5 template</title>

    <style>
        .sapUiUfdShellBackground, .sapMGlobalBackgroundColor {
            background-color: transparent !important;
            background-image: none !important;
        }

        .sapMShellGlobalInnerBackground {
            background-image: none !important;
        }
    </style>
    <script id="sap-ui-bootstrap"
        src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
        data-sap-ui-theme="sap_bluecrystal"
        data-sap-ui-xx-bindingSyntax="complex"
        data-sap-ui-libs="sap.m"></script>

    <script id="view1" type="ui5/xmlview">
        <mvc:View
          height="100%"
          controllerName="view1.initial"
          xmlns:mvc="sap.ui.core.mvc"
          xmlns:core="sap.ui.core"
          xmlns="sap.m">
            <Input
              id="productInput"
              type="Text"
              placeholder="Enter Name ..."
              showSuggestion="true"
              suggestionItems="{/}"
              suggestionItemSelected="suggestionItemSelected">
                <suggestionItems>
                  <core:Item text="{name}" />
                </suggestionItems>
            </Input>
        </mvc:View>
    </script>

</head>

<body class="sapUiBody" role="application">
    <div id="uiArea"></div>
</body>
</html>

答案 1 :(得分:-1)

问题在于我插入项目选项。我不使用suggestionItems聚合,而是使用SelectDialog https://openui5.hana.ondemand.com/explored.html#/entity/sap.m.SelectDialog/samples