on 10-28-2015 11:12 PM
Hello Experts,
I am trying to fetch the values of a list and save them in a variable (array variable). For example, in the following bin:
JS Bin - Collaborative JavaScript Debugging
The expected result would be a variable
oColors = ['Blue' , 'Brown' ,'Green' , 'Black']
By Debbugging I could see the values of the binding variable, but I could not come up with the way of saving them in an array. Thank you in advance,
Gabriel
oColors = $.map(this.byId("Farbe").getItems(), function (item, i) { return item.getKey(); } )
or
$.map(this.byId("Farbe").getItems(), function (item, i) { return item.getText(); } )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much. Both methods work perfectly. I just would like to address one small doubt:
After placing the code, the array obtains a value of [0] because the list has not been populated with items yet.
I currently place the map funcion (the solution) after the filter is executed and the filter is executed after the user clicks on each IconTabFilter:
onSelectChanged: function(oEvent) { |
var key = oEvent.getParameters().key; | |
if (key === '2') { Filter and then map function. |
At this point the data is still not in the list. What would be your suggestion to place the map function in the controller? onAfterRendering (like in the jsbin) does not give me the results.
Thank you in advance,
Gabriel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
once you do a filter on binding, you have to "push" (or notify) corresponding control that data is chnaged. method is:
/**
* Check whether this Binding would provide new values and in case it changed,
* inform interested parties about this.
*
* @param {boolean} bForceupdate
*
*/
JSONListBinding.prototype.checkUpdate = function(bForceupdate)
Hi Gabriel,
Makism solution should work. An alternative of the same using for loop: JS Bin - Collaborative JavaScript Debugging
Regards,
Sai Vellanki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.