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

Filter with dynamic Value1 in table

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

I have an OData model machine>/config and a json model runDialog.

I want to show the entires of machine>/config in a table where machine ID equals the ID of the JSON model of runDialog field machineID:

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

I tried different things for value1:

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

Nothing seems to work.Filter value1 does not contains the machine ID but the textual representation of the text set in the xml.

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

Not possible to bind dynamic filters in xml view, but can do it in JavaScript code:


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
});