Pergunta

The following is the list that i created from the device table in the database. I am printing it using table. For each row i wanted to add checkbox. how exactly can I do that?

         <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>
Foi útil?

Solução

<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>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top