on 12-29-2016 2:37 PM
I am trying to get a property from an OData list saved into a variable in javascript.
The model looks like this:
Eg. if I want to store the property Werks from list "0001", I can do it like this:
oModel.getProperty("/ZcountWerksSet('0001')/Werks")
The problem is, this is a dynamic list. I don't know what the values in the parentheses are, but I know the order of the list. Should it not be possible to do something like this then:
oModel.getProperty("/ZcountWerksSet/0/Werks")
This is not working, it returns "undefined".
How can I store the property "Werks" from the first element in the "ZcountWerks" list into a variable in JavaScript?
Hi Alexander,
As you want to get the first item always, you can use getItems()[0] method.
var oItem = oList.getItems()[0];
var path = oItem.getBindingContext().sPath;
var werks = oList.getModel().getProperty(path).Werks;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.