我是SAPUI5的新手,我的应用程序有点问题。我设置了一个主详细信息应用程序,它在主视图中显示客户列表。我的目标是将此列表筛选到oData服务的任何属性(我使用的是Northwind Webservice)。
在这里,您可以看到我的视图列表(MasterView.xml)的片段:
<List
id="list"
items="{
path: '/Customers',
sorter: {
path: 'CompanyName',
descending: false
},
groupHeaderFactory: '.createGroupHeader'
}"
busyIndicatorDelay="{masterView>/delay}"
noDataText="{masterView>/noDataText}"
mode="{= ${device>/system/phone} ? 'None' : 'SingleSelectMaster'}"
growing="true"
growingScrollToLoad="true"
updateFinished="onUpdateFinished"
selectionChange="onSelectionChange">
<infoToolbar>
<Toolbar
active="true"
id="filterBar"
visible="{masterView>/isFilterBarVisible}"
press="onOpenViewSettings">
<Title
id="filterBarLabel"
text="{masterView>/filterBarLabel}" />
</Toolbar>
</infoToolbar>
<items>
<ObjectListItem
type="{= ${device>/system/phone} ? 'Active' : 'Inactive'}"
press="onSelectionChange"
title="{CompanyName}"
numberUnit="{CustomerID}">
</ObjectListItem>
</items>
</List>
下面是我在控制器(Master.controller.js)中所做的工作:
onInit : function () {
// Control state model
var oList = this.byId("list"),
oViewModel = this._createViewModel(),
// Put down master list's original value for busy indicator delay,
// so it can be restored later on. Busy handling on the master list is
// taken care of by the master list itself.
iOriginalBusyDelay = oList.getBusyIndicatorDelay();
// Tryout Filter
var equals = FilterOperator.EQ;
var aFilterFoo = [];
aFilterFoo.push(new Filter("Country", equals, "Germany"));
var oBinding = oList.getBinding("items");
oBinding.filter(aFilterFoo);
// End tryout Filter
this._oList = oList;
// keeps the filter and search state
this._oListFilterState = {
aFilter : [],
aSearch : []
};
this.setModel(oViewModel, "masterView");
// Make sure, busy indication is showing immediately so there is no
// break after the busy indication for loading the view's meta data is
// ended (see promise 'oWhenMetadataIsLoaded' in AppController)
oList.attachEventOnce("updateFinished", function(){
// Restore original busy indicator delay for the list
oViewModel.setProperty("/delay", iOriginalBusyDelay);
});
this.getView().addEventDelegate({
onBeforeFirstShow: function () {
this.getOwnerComponent().oListSelector.setBoundMasterList(oList);
}.bind(this)
});
this.getRouter().getRoute("master").attachPatternMatched(this._onMasterMatched, this);
this.getRouter().attachBypassed(this.onBypassed, this);
},
这一切都是由SAP Web IDE自动设置的。我只更改了注释//试用过滤器和//结束试用之间的代码
当我想运行我的应用程序时,调试器会说:“无法读取未定义的属性‘filter’”,因为oBinding是未定义的。
我希望你们中的任何人都能帮助我。
非常感谢并致以最良好的问候