user1790785 user1790785 - 1 year ago 105
HTML Question

Formatting of html tables in GSP

I am using Grails and I am currently faced with this problem.

This is the result of my html table
enter image description here

And this is my code from the gsp page

<tr>
<th>Device ID</th>
<th>Device Type</th>
<th>Status</th>
<th>Customer</th>
</tr>
<tr>
<g:each in = "${reqid}">
<td>${it.device_id}</td>
</g:each>

<g:each in ="${custname}">
<td>${it.type}</td>
<td>${it.system_status}</td>
<td>${it.username}</td>
</g:each>
</tr>


So the problem is, how do I format the table such that the "LHCT271 , 2 , Thomasyeo " will be shifted down accordingly? I've tried to add the
<tr>
tags here and there but it doesn't work.. any help please?

Answer Source

I think you problem is not in the view, but in the controller (or maybe even the domain). You must have some way of knowing that reqid and custname are related if they are in the same table. You must use that to construct an object that can be easily used in a g:each

You are looking for a way to mix columns and rows, and still get a nice table. I'm afraid that is not possible.

Edit

(Sorry, I just saw the last comment.)

You cannot mix two items in a g:each.

Furthermore, if the two things are not related you probably must not put them in the same table. There will be no way for you or for Grails, to know how to properly organize the information

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download