gpt4 book ai didi

javascript - 将复选框添加到grails列表中

转载 作者:行者123 更新时间:2023-12-02 15:29:05 26 4
gpt4 key购买 nike

以下是我从数据库中的设备表创建的列表。我正在使用表格打印它。我想为每一行添加复选框。我到底该怎么做?

         <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>

最佳答案

<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>

关于javascript - 将复选框添加到grails列表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22855145/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com