0

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.

TechAffinate
  • 61
  • 1
  • 14
  • /runDialog/ is not a model name - the model name should be a string. If the model name is runDialog the reference to the variable in the model would be runDialog>/machineID – Bernard Dec 09 '20 at 14:05
  • @Bernard sorry I updated my question I did just write it down in a wrong way of course you are right, but see my updated question – TechAffinate Dec 09 '20 at 14:11
  • did you try: value1: 'runDialog>/machineID' – Bernard Dec 09 '20 at 14:20
  • @Bernard yes updated my question again, also tried that out – TechAffinate Dec 09 '20 at 14:23
  • Presumably you tried a hardcoded value for value1 and that works? – Bernard Dec 09 '20 at 14:34
  • oh - sorry - duplicate of https://stackoverflow.com/questions/25387580/not-possible-to-set-filter-value-using-data-binding – Bernard Dec 09 '20 at 14:37
  • @Bernard thanks a lot exactly this I was trying. The good news is I know that it is not possible. The bad news I don't know how to work around here. How to I assign an event handler to my table? keep in mind I will render this table multiple times so I need somehow to bind an eventHandler in the xml which calls a function where I do the dynamic filtering.... – TechAffinate Dec 09 '20 at 14:49

1 Answers1

0

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
});
York Chen
  • 744
  • 4
  • 9