0

In my XSOData service I have an entity based on calculation view with input parameters. I can to set these parameters as constants in my XML view, i.e.

<List items="{dicts>/AncParams(p_dict_name='GROUPS',p_rec_id=2)/Results}" >
        <StandardListItem
          title="{dicts>NAME}"
          />
    </List>

and it will work fine.

But how I can set parameters p_dict_name and p_rec_id dynamically? I tried to use expression bindings to get values for parameters from another model (something like this: <List items="{= ${dicts>/AncParams(p_dict_name='GROUPS',p_rec_id=${DictUIProps>/parentId})/Results} }" >) but with no luck. As I understand, expression bindings won't work. Is there any other way?

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Lev83
  • 41
  • 1
  • 7
  • I think thats the way. Read it, store these values (as a total list) and apply the filter via java script. Means expression binding on the list via a local model is correct, but without these filtering in the expression. will be difficult with an expression, but anyway it should be possibe https://help.sap.com/doc/saphelp_pobuilder10/1.0.05/de-DE/da/f6852a04b44d118963968a1239d2c0/content.htm?no_cache=true – dotchuZ Apr 22 '18 at 18:11

1 Answers1

1

As far as I'm aware you can't do the aggregation binding dynamically through XML. At least not in the versions I have used and I have to admit I haven't re-checked in a while. The string never gets interpreted for inner bindings before it's applied to the model.

The way I do this is through the controller:

<List id="myList" />

and in your controller (onBeforeRendering or onPatternMatched or wherever your model and view are known to the controller):

this.getView().byId('myList').bindItems({
  model: 'dicts',
  path: `{/AncParams(p_dict_name='${p_dict_name}',p_rec_id=${p_rec_id})/Results}`,
  template: new sap.m.StandardListItem({
    title: '{dicts>NAME}'
  })
});

you can use the getModel('dicts').createKey function to generate the path name which is a little cleaner I suppose.

This is the way to apply dynamic filters as well, In case you ever build those.

Jorg
  • 7,219
  • 3
  • 44
  • 65
  • My used version is 1.28. Well, I wrote this code just for test purposes, in fact I want to use this approach in my custom control (it will have `items` aggregation too). Is it true, that I should redefine `onBeforeRendering` in my custom control and bind `items` aggregation in this method like in your code snippet? – Lev83 Apr 23 '18 at 20:54
  • In a custom control I do things generally in the onBeforeRendering method too, yes, but it depends a little what are you trying to make. Are you extending the list and providing a dict_name parameter? – Jorg Apr 23 '18 at 22:12
  • I want to make breadcrumbs with some augments. In item I need a link + icon, so it will be a `BreadcrumbItem` extends a `sap.m.Link`. For container I plan to create `Breadcrumb` which extends a `Control` and contains `items` aggregation and `root` aggregation. – Lev83 Apr 24 '18 at 17:55