SAP UI5

时间:2017-06-22 21:46:37

标签: javascript sapui5

我已经在UI5中完成了一些复杂的事情但是今天不知何故我陷入其中,在我用它附加模型后,我的下拉列表根本没有填充。我不确定我犯的是什么错误:(

我的XML视图:

<Panel headerText="Pump Filter" expandable="true" id="filterPanel" expand="onPanelExpand">
    <content>
        <f:SimpleForm editable="true" layout="ResponsiveGridLayout" id="mainform">
        <f:content>
        <Label id="idPumpLabel" visible="true" text="Pump"></Label>
        <Select id="pumpSelect" items="{ path: '/Rowsets/Rowset/0/Row'}" change="onPumpSelect" forceSelection="false" width="200px">
                    <core:Item key="{ID_PUMP}" text="{DS_PUMP}" />
        </Select>
        </f:content>
        </f:SimpleForm>
    </content>
    </Panel>

在我的控制器中,在Oninit函数中,以下是我的代码:

onInit: function(){

                var that = this;

                this.getView().addEventDelegate({
                    onBeforeShow: function () {


                        var oData = {
                                   "Rowsets":{
                                          "DateCreated":"2016-08-04T8:15:47",
                                          "Version":"15.0 SP6 Patch 3 (Mar 23, 2016)",
                                          "StartDate":"2016-08-04T8:15:47",
                                          "EndDate":"2016-08-04T8:15:47",
                                          "CachedTime":"",
                                          "Rowset":[
                                             {
                                                "Columns":{
                                                   "Column":[
                                                      {
                                                         "Name":"ID_PUMP",
                                                         "SourceColumn":"ID_PUMP",
                                                         "Description":"ID_PUMP",
                                                         "SQLDataType":4,
                                                         "MinRange":1,
                                                         "MaxRange":1
                                                      },
                                                      {
                                                         "Name":"DS_PUMP",
                                                         "SourceColumn":"DS_PUMP",
                                                         "Description":"DS_PUMP",
                                                         "SQLDataType":12,
                                                         "MinRange":1,
                                                         "MaxRange":1
                                                      }
                                                   ]
                                                },
                                                "Row":[
                                                   {
                                                      "ID_PUMP":100,
                                                      "DS_PUMP":"Pump_100"
                                                   },
                                                   {
                                                      "ID_PUMP":200,
                                                      "DS_PUMP":"Pump_200"
                                                   },
                                                   {
                                                      "ID_PUMP":300,
                                                      "DS_PUMP":"Pump_300"
                                                   }
                                                ]
                                             }
                                          ]
                                       }
                                    };

                    var oPumpModel = new sap.ui.model.json.JSONModel(oData);
                    that.byId("pumpSelect").setModel(oPumpModel);


                    }

                });

            },

但不知何故,下拉是空白的。没有填充任何价值。

我做错了什么?

谢谢!

1 个答案:

答案 0 :(得分:0)

我需要添加聚合才能使其正常工作:

<Select id="pumpSelect" items="{/Rowsets/Rowset/0/Row}">
     <items>
          <core:Item key="{ID_PUMP}" text="{DS_PUMP}" />
     </items>
</Select>