Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8729341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:49:00+00:00 2026-06-13T08:49:00+00:00

I have two domains in a Grails application with a one-to-many relationship: Course and

  • 0

I have two domains in a Grails application with a one-to-many relationship: Course and Person. One course may have many people. When I view show.gsp for Course, it will show a list of all person’s names who are registered for the Course.

I want that list to be sorted alphabetically by last name. However, each time that I refresh show.gsp, the order of the list changes (can’t seem to identify a pattern). I set up a mapping in my Person domain to sort by lastName “asc”, but that has no effect.

I had modified the scaffolded show.gsp to display the names in a table along with additional checkboxes. Here is that modified code:

<g:if test="${courseInstance?.persons}">
            <br />
            <table>
                <thead>
                    <tr>
                        <th>#</th>
                        <g:sortableColumn property="person"
                            title="${message(code: 'person.lastName.label', default: 'Person')}" />
                        <g:sortableColumn property="paid"
                            title="${message(code: 'person.paid.label', default: 'Paid')}" />
                        <g:sortableColumn property="attended"
                            title="${message(code: 'person.attended.label', default: 'Attended')}" />
                    </tr>
                </thead>
                <tbody>
                    <g:set var="counter" value="${1}" />
                    <g:each in="${courseInstance.persons}" status="i" var="p">
                        <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
                            <td>
                                ${counter}
                            </td>
                            <td class="property-value" aria-labelledby="persons-label"><g:link
                                    controller="person" action="show" id="${p.id}">
                                    ${p?.encodeAsHTML()}
                                </g:link></td>
                            <td><g:checkBox name="paid" value="${p.paid}"
                                    onclick="${remoteFunction(action:'togglePaid', id:p.id,
                                params:'\'completed=\' + this.checked')}" /></td>
                            <td><g:checkBox name="attended" value="${p.attended}"
                                    onclick="${remoteFunction(action:'toggleAttended', id:p.id,
                                params:'\'completed=\' + this.checked')}" /></td>
                        </tr>
                        <g:set var="counter" value="${counter + 1}" />
                    </g:each>
                </tbody>
            </table>
        </g:if>

Is there any modification I can make either in show.gsp or the domain to have the list sorted alphabetically by default (unless a sortable column is clicked)?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:49:01+00:00Added an answer on June 13, 2026 at 8:49 am

    Could you show how you have it set on the Domain Level? It should like like so…

    class Person {
        …
        static mapping = {
            sort "lastName"
        }
    }
    

    Check out the documentation here. If the sorting does seem to be correct but still not working you could try stopping the app and doing a grails clean and re-running it.

    UPDATE:
    answer is the comments below…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes in Grails application , Employee has hasMany(one To Many relations)
I have two CDN domains, one that delivers content over https and the other
I have two domains. One domain contains the login script. It creates a cookie
I have the next two domain classes in a grails application: class Room {
Grails 2.1.1, mongodb 1.0.0.GA. I have two domain classes: class Person { String firstName
I have two domains sitting on the one webserver. I have images and other
I have two domains, one is a .com domain and the other is a
I have two domains which are similar, mysite1.com and mysite2.com I only have one
I have two domains. One is www.nucleation.co.in and another www.nucleation.in How can I redirect
I have two domains. One production. One testing. There is no trust between the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.