我有一个由OData填充的表,但我希望它在首次加载页面时不会填充。
在用户首先在组合框中选择一个选项之前,我怎么能将它变为空?是否假设视图,控制器或清单发生了变化?
<ComboBox id="officeComboBox"
width="100%"
placeholder="Office"
selectionChange=".officeComboChange"
>
<items>
<core:Item key="{OFFICE_CODE}" text="{OFFICE_CODE}" textDirection="RTL"/>
</items>
</ComboBox>
<!-- ... -->
<Table id="statTable"
noDataText="Initializing Data"
growing="true"
includeItemInSelection="true"
headerText="EST"
items="{/ESTSet}"
>
处理器officeCodeChange
适用于在组合框选择后在桌面上显示正确的项目
onInit: function() {
var oViewModel, iOriginalBusyDelay, oTable = this.byId("officeCombo");
this._oTableSearchState = [];
},
officeCodeChange: function(event) {
var aFilters = [];
var officeCode = event.getParameter("selectedItem").getText();
var filter = new Filter("EST_ID", sap.ui.model.FilterOperator.Contains, officeCode);
var list = this.getView().byId("statTable");
var binding = list.getBinding("items");
binding.filter(aFilters.concat(filter), "Application");
},
items="{/ESTSet}"
和相应的模板控件。bindItems
与创建的过滤器结合使用:
officeCodeChange: function(event) {
const filter = /*...*/;
const table = this.byId("statTable");
const listBinding = table.getBinding("items");
if (listBinding) {
listBinding.filter(filter);
} else {
this.bindStats(table, filter);
}
},
bindStats: function(table, filter) {
table.bindItems({
path: "/ESTSet",
filters: [filter],
template: new ColumnListItem({ // required from "sap/m/ColumnListItem"
//...
}),
});
},