Every time I select a checkbox on a listing page, save it, then navigate to another page through pagination and select a checkbox there, the checkbox on my initial page gets unchecked. I've considered using AJAX to store checked checkboxes in Grails session but I'm not sure how to implement it - I am new to JavaScript and working with views. Can someone provide assistance? Here is the section where all companies are listed along with checkboxes in my GSP:
<g:form name="company-list-form" action="listCompany">
<div>
<g:textField id="search-field" name="query" value="${params.query}"/>
<span>
<g:checkBox id="only-blockades-box" name="onlyBlockades" class="submit-on-change" value="${params.onlyBlockades}" title="Show only blockades"/>
<label for="only-blockades-box">Only Blockades</label>
</span>
<g:actionSubmit value="${message(code: 'default.buttons.search', default: 'Search')}" action="listCompany" class="button_orange"/>
<g:link action="listCompany" class="button_gray"><g:message code="default.buttons.clean" default="Clear"/></g:link>
</div>
<div class="padding-top">
<table class="table_td company-list-table">
<tbody>
<tr class="gray2">
<th class="first">Id</th>
<th style="max-width: 100px;">Name</th>
... (remaining code omitted for brevity)
if (flash.message) {
params.errors = flash.message
}
[companyInstanceList: companyInstanceList, companyInstanceTotal: count, companySaved: params.companySaved, errors: params.errors]
}
To resolve this issue and retain the checked status of checkboxes after saving, one approach could be to modify the AJAX functionality to store the checkbox state in the Grails session. This way, when navigating between pages, the checkbox selections will remain persistent. You may need to update both the client-side JavaScript and the server-side controller logic to handle this implementation.