Warm tip: This article is reproduced from serverfault.com, please click

javascript-在表格中使用动态Value1进行过滤

(javascript - Filter with dynamic Value1 in table)

发布于 2020-12-09 13:47:08

我有一个OData模型机> / config和一个json模型runDialog。

我想在一个表中显示machine> / config的全部内容,其中machine ID等于runDialog字段machineID的JSON模型的ID:

<Table id="tableMachineConfig"
items="{path:'machine>/config', filters: [{path: 'machine>id', operator: 'EQ', value1: 
'{runDialog>/machineID}'}], sorter: {path: 'machine>type'}}">

我为value1尝试了不同的方法:

value1: '{runDialog>/machineID}'
value1: {runDialog>/machineID}
value1: {path: 'runDialog>/machineID'}
value1: '{path: 'runDialog>/machineID'}'
value1: 'runDialog>/machineID'

似乎没有任何作用。过滤器value1不包含计算机ID,但包含xml中设置的文本的文本表示形式。

Questioner
Mac
Viewed
0
York Chen 2020-12-10 14:24:45

无法在xml视图中绑定动态过滤器,但可以在JavaScript代码中进行绑定:


var oTable = sap.ui.getCore().byId("tableMachineConfig");
var oFilters = [new sap.ui.model.Filter("Pa", sap.ui.model.FilterOperator.EQ, pacode),
    new sap.ui.model.Filter("PfNum", sap.ui.model.FilterOperator.EQ, pfcode),
    new sap.ui.model.Filter("Psa", sap.ui.model.FilterOperator.EQ, psacode)
];
oTable.bindAggregation("items", {
    path: 'machine>/config',
    filters: oFilters
});