以下是我从数据库中的设备表创建的列表。我正在用桌子打印它。对于每行我想添加复选框。我怎么能这样做?
<table>
<thead>
<tr>
<g:sortableColumn property="dname" title="${message(code: 'devices.dname.label', default: 'Dname')}" />
<g:sortableColumn property="owner" title="${message(code: 'devices.owner.label', default: 'Owner')}" />
<g:sortableColumn property="serailNumber" title="${message(code: 'devices.serailNumber.label', default: 'Serail Number')}" />
<g:sortableColumn property="supportingAndroidVersion" title="${message(code: 'devices.supportingAndroidVersion.label', default: 'Supporting Android Version')}" />
</tr>
</thead>
<tbody>
<g:each in="${Devices.list()}" status="i" var="devicesInstance">
<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
<td>${fieldValue(bean: devicesInstance, field: "dname")}</td>
<td>${fieldValue(bean: devicesInstance, field: "owner")}</td>
<td>${fieldValue(bean: devicesInstance, field: "serailNumber")}</td>
<td>${fieldValue(bean: devicesInstance, field: "supportingAndroidVersion")}</td>
</tr>
</g:each>
</tbody>
</table>
答案 0 :(得分:1)
<table>
<thead>
<tr>
<td></td>
<g:sortableColumn property="dname" title="${message(code: 'devices.dname.label', default: 'Dname')}" />
<g:sortableColumn property="owner" title="${message(code: 'devices.owner.label', default: 'Owner')}" />
<g:sortableColumn property="serailNumber" title="${message(code: 'devices.serailNumber.label', default: 'Serail Number')}" />
<g:sortableColumn property="supportingAndroidVersion" title="${message(code: 'devices.supportingAndroidVersion.label', default: 'Supporting Android Version')}" />
</tr>
</thead>
<tbody>
<g:each in="${Devices.list()}" status="i" var="devicesInstance">
<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
<td><g:checkbox name="myCheckbox${i}" value="${true}"/></td>
<td>${fieldValue(bean: devicesInstance, field: "dname")}</td>
<td>${fieldValue(bean: devicesInstance, field: "owner")}</td>
<td>${fieldValue(bean: devicesInstance, field: "serailNumber")}</td>
<td>${fieldValue(bean: devicesInstance, field: "supportingAndroidVersion")}</td>
</tr>
</g:each>
</tbody>
</table>