mardi 9 octobre 2018

Pagination resets checked rows

I have a GSP containing some rows with an checkbox which lets the user select several rows.

 <table>
<thead>
    <tr>
    // Column headers
    </tr>
</thead>
<tbody>
    <g:each in="${itemList}" status="i"
                var="instance">
        <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
            // Some other rows
            <td>
                <g:checkBox name="selected"
                                value="${instance.id}"
                                checked="false" />
            </td>
        </tr>
    </g:each>
</tbody>

And a pagination under my table:

    <div class="pagination">
        <g:paginate total="${total}" params="${params}"/>
    </div>

Now the problem is when I switch from Page 1 -> Page 2 -> and then back to Page 1 all the checkboxes from Page 1 are reseted.

As pagination calls the list controller method I checked the following on page switch by Watching the following in Debugger when list controller method gets called:

params.list('selected')

But unfortunately the list is empty.




Aucun commentaire:

Enregistrer un commentaire