How to display values using of an array using for loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2015 02:45 AM
Hi All,
In my table there is a field "Team" of type "List". I'm selecting more than one member in that field. Now I want to display the values of that filed one after another.
code:
<td>$[escalation.u_team.getDisplayValue()]</td>
When I try to display the values using the above code, I got the result as "Quintin Isacson, Waldo Edberg".
I need the values to be displayed in the below format:
Quintin Isacson
Waldo Edberg
I used foreach tag but it is not working.
Here is the code using "foreach"
<tr>
<td class="a2_td">
<g:evaluate>
var list = escalation.u_team.getDisplayValue();
<!--var array = list.split(","); -->
</g:evaluate>
<j:forEach items="${list}" var="jvar_array">
<g:evaluate jelly="true">
var name = jelly.jvar_array;
</g:evaluate>
<p>
User: $[SP] <span>${name}</span>
</p>
</j:forEach>
</td></tr>
Any clue on how to make this code work?
Thanks,
Jennifer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2015 04:47 AM
Hi Jan,
Value is not getting printed. According to my observation the values should be with in [' '](square brackets).
I tried below example and did some changes also, then finally came to know that to display values, it should be with in [].
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate>
var colors =['red', 'yellow'];
</g:evaluate>
<j:forEach items="${colors}" var="jvar_color">
<g:evaluate jelly="true">
var name=jelly.jvar_color;
</g:evaluate>
<p>
Color: $[SP] <span>${name}</span>
</p>
</j:forEach>
</j:jelly>
So, I'm not exactly getting where I'm doing mistake in my code.
Thanks,
Jenny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2015 04:19 PM
Try this code:
<g:evaluate>
var colors = ['red', 'yellow'];
</g:evaluate>
<j:forEach items="${colors}" var="jvar_thisColor" indexVar="jvar_i">
<g:evaluate var="jvar_s" expression="colors[${jvar_i}]" />
<p>${jvar_s}</p>
</j:forEach>
Let me know if this helps.
-Jan Raphael Caasi