List in gsp

22 views
Skip to first unread message

Jagriti Srivastava

unread,
Sep 5, 2018, 7:46:24 AM9/5/18
to Grails Dev Discuss
Hello , I need a help . I want to show list in gsp table . The list is as follows 

student = [[students.StdAsgn : 1, students.StdAsgn : 2, students.StdAsgn : 3], [students.StdAsgn : 4, students.StdAsgn : 5, students.StdAsgn : 6]]

which is send to the template as render(template:'studentList' ,model: [std:students])'
and got the list in table using g:each as 
<g:each var="s" in="${std}">
    <tr>
<td>${s[0].student.stdName}</td>
<td>${s[0].student.stdEmail}</td>
<td>${s[0].student.phNum}</td>
<td>${s.assignment.aName}</td>
<td>${s.student}</td>
<td>${s.status}</td>
</tr>
</g:each>

and the table shown in is as follows :
NameEmailPhone NoAssignment NameURLAction
Sagar Budhathokis...@std.com1234567890[C Programming Assignment, Assignment 1, asgn 3][students.Student : 1, students.Student : 1, students.Student : 1][false, false, false]
Kabita Olik...@123.com0987654321[C Programming Assignment, Assignment 1, asgn 3][students.Student : 2, students.Student : 2, students.Student : 2][false, false, false]
Showing 1 to 2 of 2 entries

 

but i want to get table in the following ways.
NameEmailPhone NoAssignment NameURLAction
Sagar Budhathokis...@std.com1234567890C Programming Assignment, 
Assignment 1
 asgn 3
students.Student : 1
students.Student : 1
students.Student : 1
false
 false 
false
Kabita Olik...@123.com987654321C Programming Assignment
Assignment 1
asgn 3
students.Student : 2
students.Student : 2
students.Student : 2
false
 false
 false

 How to divide one into multiple rows using grails  


NGUYEN Vu Ngoc Tung

unread,
Oct 4, 2018, 8:35:02 AM10/4/18
to Grails Dev Discuss
Hello,It's not a big deal. Your problem could be resolved by using
${s[0].student.phNum}
$
{String.join("<br/>", s.assignment.aName)}
$
{String.join("<br/>", s.student)}
$
{String.join("<br/>", s.status)}


Please reference to another detailed discussion about  How to join array elements with a separator.

Have a good luck!
T. Nguyen

Jagriti Srivastava

unread,
Oct 8, 2018, 1:43:23 AM10/8/18
to grails-de...@googlegroups.com
Thank you so much .

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/7c681cd2-f33c-4972-b317-55fa76ed2f48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages