openui5
openui5 copied to clipboard
relative path in JsonModel.getProperty()
Imagine a code like this
onPress : function(oEvent) {
var path = oEvent.getSource().getBindingContext().getPath();
var oModel = this.getView().getModel();
var obj = oModel.getProperty(path);
}
You get a path, hence you know you are in /database/0/connection/4/name but very likely you will need elements from parents as well. Only solution is to split the string and construct the path again, e.g. oModel.getProperty(/database/0/connection/4/host); or oModel.getProperty(/database/0/databasetype);
With relative path support that would be easier:
oModel.getProperty(path + "/../host");
Or even better: A set of methods to navigate programatically, e.g.
oModel.getNode(path).getParentNode().getProperty();
Hello @wernerdaehn , Thank you for share your enhancement proposal. I've created an internal incident 1980265594. The status of the issue will be updated here in GitHub. Regards, Diana
As discussed in issue/2504:
@wernerdaehn original example for relative binding paths in composite bindings:
Imagine the situation where you use a JsonModel as the source of your e.g. tree table with databasevendor -> databaseversion -> connectioninfo.
If somebody does something on the connectioninfo level, it is very likely he will need the parent version as well, e.g. a formatter creating the link for the connection info screen.
If you could specify things like "{ parts: [ 'connectionname', '../databaseversion', '../../databasevendor'] }"
Hi @wernerdaehn ,
I have logged your requirement as CPOUI5MODELS-900 internally consisting of two parts:
Acceptance Criteria
- It is possible to specify paths containing ../ in sap.ui.model.json.JSONModel#getProperty.
- It is possible to specify relative paths with ../ in property bindings when a JSONModel is used.
Unfortunately, I cannot provide any forecast as to when this could get addressed.
Best regards Mathias.