Note that there are some explanatory texts on larger screens.

plurals
  1. POGrails - Refreshing object list using checkbox?
    primarykey
    data
    text
    <p>So I'm diving into Grails for the first time and am trying to accomplish what I think would be an easy task, so I hope this is trivial. Time spent on it is making me feel otherwise :)</p> <p>So I have a list of Contacts in a database that are tied to a boolean called isActive. I want to have a check box in my list gsp that determines whether to show inactive members or not.</p> <p>I've tried using a Javascript function (which I could successfully call, but wasn't sure how to handle the passing after the call). I've also tried to add a g:if to check to see if the box's checked property was enabled, but this results in a null object (which I suspected would happen).</p> <p>I've also tried attaching a remoteFunction call on the onclick of the checkbox, but I never get a response back unfortunately.</p> <p>Any advice? Thanks - I appreciate it. The challenges of teaching yourself a web language for the first time :)</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta name="layout" content="main"&gt; &lt;g:set var="entityName" value="${message(code: 'contact.label', default: 'Contact')}" /&gt; &lt;title&gt;&lt;g:message code="default.list.label" args="[entityName]" /&gt;&lt;/title&gt; &lt;g:javascript&gt; function updateThisPage() { } &lt;/g:javascript&gt; &lt;/head&gt; &lt;body&gt; &lt;a href="#list-contact" class="skip" tabindex="-1"&gt;&lt;g:message code="default.link.skip.label" default="Skip to content&amp;hellip;"/&gt;&lt;/a&gt; &lt;div class="nav" role="navigation"&gt; &lt;ul&gt; &lt;li&gt;&lt;a class="home" href="${createLink(uri: '/')}"&gt;&lt;g:message code="default.home.label"/&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;g:link class="create" action="create"&gt;&lt;g:message code="default.new.label" args="[entityName]" /&gt;&lt;/g:link&gt;&lt;/li&gt; &lt;li&gt;&lt;g:checkBox name="showInactives" value="${false}" onclick="....." /&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div id="list-contact" class="content scaffold-list" role="main"&gt; &lt;h1&gt;&lt;g:message code="default.list.label" args="[entityName]" /&gt;&lt;/h1&gt; &lt;g:if test="${flash.message}"&gt; &lt;div class="message" role="status"&gt;${flash.message}&lt;/div&gt; &lt;/g:if&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;g:if test="${isActive?.checked}"&gt; &lt;g:sortableColumn property="firstName" title="${message(code: 'contact.firstName.label', default: 'First Name')}" /&gt; &lt;g:sortableColumn property="lastName" title="${message(code: 'contact.lastName.label', default: 'Last Name')}" /&gt; &lt;g:sortableColumn property="phone" title="${message(code: 'contact.phone.label', default: 'Phone')}" /&gt; &lt;g:sortableColumn property="email" title="${message(code: 'contact.email.label', default: 'Email')}" /&gt; &lt;g:sortableColumn property="title" title="${message(code: 'contact.title.label', default: 'Title')}" /&gt; &lt;g:sortableColumn property="jobFunc" title="${message(code: 'contact.jobFunc.label', default: 'Job Func')}" /&gt; &lt;/g:if&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;g:each in="${contactInstanceList}" status="i" var="contactInstance"&gt; &lt;g:if test="${contactInstance.isActive}"&gt; &lt;tr class="${(i % 2) == 0 ? 'even' : 'odd'}"&gt; &lt;td&gt;&lt;g:link action="show" id="${contactInstance.id}"&gt;${fieldValue(bean: contactInstance, field: "firstName")}&lt;/g:link&gt;&lt;/td&gt; &lt;td&gt;${fieldValue(bean: contactInstance, field: "lastName")}&lt;/td&gt; &lt;td&gt;${fieldValue(bean: contactInstance, field: "phone")}&lt;/td&gt; &lt;td&gt;${fieldValue(bean: contactInstance, field: "email")}&lt;/td&gt; &lt;td&gt;${fieldValue(bean: contactInstance, field: "title")}&lt;/td&gt; &lt;td&gt;${fieldValue(bean: contactInstance, field: "jobFunc")}&lt;/td&gt; &lt;/tr&gt; &lt;/g:if&gt; &lt;/g:each&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;div class="pagination"&gt; &lt;g:paginate total="${contactInstanceTotal}" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload