2017-01-19 27 views
0

私はOdataサービスからデータを取得しようとしています。私の要件は、valueHelpDialogを使用して行を選択すると複数の入力フィールドに選択された行データを取得するときです。検索ヘルプの値をFetch valueHelpDialog複数のフィールドに入力

出力:

選択されたIDは、一つのフィールドに入ったが、私の要件はまた、残りの2つのフィールドに取得したいと私のコードを以下に添付されるよう:

<View 
xmlns="sap.m" 
xmlns:l="sap.ui.layout" 
xmlns:core="sap.ui.core" 
xmlns:mvc="sap.ui.core.mvc" 
xmlns:html="http://www.w3.org/1999/xhtml" 
xmlns:f="sap.ui.layout.form" 
controllerName="Navigation.controller.View2"> 
<Page 
    title="Second Page" 
    showNavButton="true" 
    navButtonPress="onBack"> 
    <content> 
    <l:VerticalLayout 
    class="sapUiContentPadding" 
    width="100%"> 
    <Label text= "Orderinput" width="300px"/> 
    <MultiInput id= "input" showValueHelp= "true" width="300px" valueHelpRequest= "handlef4"/> 

    <l:HorizontalLayout> 
    <Label text="planPlant" /> 
     <Input id="InputNoEdit" class="sapUiSmallMarginBottom" type="Text" 
      enabled="True" editable="false" width="300px"/> 

    <Label text="Description" /> 
     <Input id="InputNoEdit2" class="sapUiSmallMarginBottom" type="Text" 
      enabled="True" editable="false" width="300px"/> 
    </l:HorizontalLayout> 

    <l:HorizontalLayout> 
    <Label text="Product not editable" /> 
     <Input id="InputNoEdit3" class="sapUiSmallMarginBottom" type="Text" 
      enabled="True" editable="false" width="300px"/> 
    <Label text="Product editable" /> 
     <Input id="InputEdit1" class="sapUiSmallMarginBottom" type="Text" 
      enabled="true" editable="true" width="300px"/> 
    </l:HorizontalLayout> 

    <l:HorizontalLayout> 
    <Label text="Product editable" /> 
     <Input id="InputEdit2" class="sapUiSmallMarginBottom" type="Text" 
      enabled="true" editable="true" width="300px"/> 
    <Label text="simple DatePicker" labelFor="DP1"/> 
     <DatePicker 
     id="DP1" 
     placeholder="Enter Date ..." 
     change="handleChange" 
     class="sapUiSmallMarginBottom"/> 
    </l:HorizontalLayout> 

    <l:HorizontalLayout> 
    <Button type="Accept" 
        text="Accept" 
        press="onPress" 
        ariaDescribedBy="acceptButtonDescription genericButtonDescription"/> 
    <Button type="Cancel" 
        text="Cancel" 
        press="onPress2" 
        ariaDescribedBy="acceptButtonDescription genericButtonDescription"/> 
    </l:HorizontalLayout> 
    </l:VerticalLayout> 
    <!--</f:SimpleForm>--> 
    </content> 
</Page> 

コントローラコード:

jQuery.sap.require("sap.ui.comp.valuehelpdialog.ValueHelpDialog"); 

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

return Controller.extend("Navigation.controller.View2", { 
handlef4: function(){ 

    var oInput = sap.ui.getCore().byId("__xmlview1--input"); 
    var oInput2 = sap.ui.getCore().byId("__xmlview1--planPlant"); 
    if(!this._oValueHelpDialog){ 
     this._oValueHelpDialog = new sap.ui.comp.valuehelpdialog.ValueHelpDialog("idValueHelp",{ 
     supportMultiselect: false, 
     supportRangesOnly: false, 
     stretch: sap.ui.Device.system.phone, 
     keys: "Orderid", 
     descriptionKey: "Orderid", 
     filtermode: "true", 
     ok: function(oEvent){ 
      var aTokens = oEvent.getParameter("tokens"); 
      oInput.setTokens(aTokens); 
       this.close(); 
     }, 
     cancel: function(){ 
      this.close(); 
     } 
     }); 
    } 


     var oFilterBar = new sap.ui.comp.filterbar.FilterBar({ 
     advancedMode: true, 
     // filterBarExpanded: false, 
     filterBarExpanded: true, 
     showGoOnFB: !sap.ui.Device.system.phone, 
     filterGroupItems: [new sap.ui.comp.filterbar.FilterGroupItem({ groupTitle: "foo", groupName: "gn1", name: "n1", label: "Orderid", control: new sap.m.Input()}), 
          new sap.ui.comp.filterbar.FilterGroupItem({ groupTitle: "foo", groupName: "gn1", name: "n2", label: "Description", control: new sap.m.Input()}), 
          new sap.ui.comp.filterbar.FilterGroupItem({ groupTitle: "foo", groupName: "gn1", name: "n3", label: "Planplant", control: new sap.m.Input()})], 

     search: function(oEvt) { 
      var oParams = oEvt.getParameter("selectionSet"); 
      var iOrder = oParams[0].getValue(); 
      var iType = oParams[1].getValue(); 
      var iPlan = oParams[2].getValue(); 
      // sap.m.MessageToast.show("Search pressed '"); 
    oTable.bindRows({path: "/OrderDataSet", filters: [ 
    new sap.ui.model.Filter("Orderid",sap.ui.model.FilterOperator.EQ, iOrder), 
    new sap.ui.model.Filter("Description",sap.ui.model.FilterOperator.EQ, iType), 
    new sap.ui.model.Filter("Planplant",sap.ui.model.FilterOperator.EQ, iPlan)] 
     }); 
     } 
    });   

    this._oValueHelpDialog.setFilterBar(oFilterBar); 
    var oColModel = new sap.ui.model.json.JSONModel(); 
    oColModel.setData({ 
     cols: [ 
       {label: "Orderid", template: "Orderid"}, 
       {label: "Description", template: "Description"}, 
       {label: "Planplant", template: "Planplant"} 
      ] 
    }); 
    var oTable = this._oValueHelpDialog.getTable(); 
    oTable.setModel(oColModel,"columns"); 
    var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/SAP/ZP01_FIORI_SRV_01/"); 
    oTable.setModel(oModel); 
    this._oValueHelpDialog.open(); 
    }, 
     onBack : function() { 
     var sPreviousHash = History.getInstance().getPreviousHash(); 
     if (sPreviousHash !== undefined) { 
      window.history.go(-1); 
     } else { 
      this.getOwnerComponent().getRouter().navTo("page1", null, true); 
     } 
    } 
}); 

}); 

答えて

0

私は(あなたが唯一のいくつかのことを変更する必要があります)、次のデータに私の解決策をベースにします:

enter image description here

を、私は、私が市を表示する2つのテキストフィールドを持つことになりますと、 CurrencyCode(行iの選択時に、e。 'Ok'メソッド)。 enter image description here

XMLコード:以下

は、UIがどのように見えるかです

<f:SimpleForm 
     minWidth="1024" 
     maxContainerCols="2" 
     editable="true" 
     layout="ResponsiveGridLayout" 
     labelSpanL="3" labelSpanM="3" labelSpanS="12" 
     emptySpanL="0" emptySpanM="0" emptySpanS="0" 
     columnsL="1" columnsM="1" 
     class="editableForm"> 
     <f:content> 
      <m:Label text="Company"/> 
      <m:MultiInput id="multiInput" valueHelpRequest="onValueHelpRequest"/> 
      <m:Label text="City"/> 
      <m:Text text='' id='city'/> 
      <m:Label text="Currency" /> 
      <m:Text text='' id='currency'/> 
     </f:content> 
    </f:SimpleForm> 

は、任意のフィールドの選択に、私はUIに市とCURRENCYCODEに移入されます。以下は、私のコードは次のとおりです。

onValueHelpRequest: function() { 
    var that= this; 

が、これはあなたの問題を解決するかどうか私に教えてください:

 ok: function(oControlEvent) { 
      that.aTokens = oControlEvent.getParameter("tokens"); 
      that.theTokenInput.setTokens(that.aTokens); 
      var oTable = oValueHelpDialog.getTable(); 
      var oContext = oTable.getContextByIndex(oTable.getSelectedIndex()).getObject(); 
      that.getView().byId('city').setText(oContext.City); //fetch description. 
      that.getView().byId('currency').setText(oContext.CurrencyCode); //fetch Plant code. 
      oValueHelpDialog.close(); 
     }, 

私はこれまで、ValueHelpHandler(F4)にすることを設定しましたのでご注意ください。

関連する問題