Reputation: 101
I'm looking for a way to bind a field to some aggregate value, based on the value in another attribute. I know there are several other ways to do this, but if I can make this work, it'll be considerably better than my alternatives.
This is what I have so far, using expression binding:
<Text text="{= ${path:'/ProjectStatus(${key})/status'} }"/>
Purpose: Bind to the ProjectStatus object that matches the key attribute of the current object, and get the status attribute from that.
Thanks in advance!
Upvotes: 0
Views: 51
Reputation: 1920
Sorry, that won't work. You can't use expression binding for this purpose. Expression binding is quite powerful, but meant for formatting and a little bit of math, not for defining bindings.
It would also not be advisable to solve it this way. If you want to create a key for and entity, you should always use the createKey
method of your ODataModel, to make sure that key follows the syntax corresponding with the property type. E.g.: /ProjectStatus('ABC')
for a key of type String
, or /ProjectStatus(123)
for a key of type Int
.
Best is to get your controller to perform a bindElement
on the Text control. Something similar to this:
this.getView().byId("TextId").bindElement(
oModel.createKey("/ProjectStatus", { Id: sKey })
);
After that you could just use <Text text="{status}" />
to show the status of the project.
Upvotes: 1