组合框选择后填充表

问题描述 投票:1回答:1

我有一个由OData填充的表,但我希望它在首次加载页面时不会填充。

在用户首先在组合框中选择一个选项之前,我怎么能将它变为空?是否假设视图,控制器或清单发生了变化?

View

<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}"
>

Controller

处理器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");
},
sapui5
1个回答
1
投票
  1. 从视图中删除初始聚合绑定items="{/ESTSet}"和相应的模板控件。
  2. 将高级API 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" //... }), }); },
© www.soinside.com 2019 - 2024. All rights reserved.