openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

relative path in JsonModel.getProperty()

Open wernerdaehn opened this issue 5 years ago • 3 comments

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

wernerdaehn avatar Apr 29 '19 09:04 wernerdaehn

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

Shtilianova avatar May 14 '19 08:05 Shtilianova

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'] }"

Thodd avatar May 14 '19 11:05 Thodd

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.

uhlmannm avatar Mar 14 '22 18:03 uhlmannm