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 7809859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:34:01+00:00 2026-06-02T03:34:01+00:00

Suppose I have two domain objects, Document and Author Class Document { Author author

  • 0

Suppose I have two domain objects, Document and Author

Class Document {
    Author author
    String title
}

Class Author {

    String lastName
    String firstName

    String toString() {

        return lastName + ", " + firstName
    }
}

The view list.gsp looks something like this:

<g:sortableColumn property="title" title=... />
<g:sortableCOlumn property="author" title=... />

....

<td>${fieldValue(bean: documentInstance, field: "author"}></td>
<td>${fieldValue(bean: documentInstance, field: "title"}></td>

The displayed values in the table work as intended – the table row will show the author as (lastName, firstName) next to documentInstance.title.

However, clicking the Author column header to sort causes “documents” to be sorted by author.id .

What is the most expedient way to get sorting by author.toString() or “author.lastName, author.firstName” instead of sorting by author.id?

I’d prefer to avoid falling back to .withCriteria{} if possible – I have four different columns that need this functionality, and it seems like that would get messy.

  • 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-02T03:34:03+00:00Added an answer on June 2, 2026 at 3:34 am

    I’m just a Grails beginner so maybe my answer is not optimal, but this was the easiest way for me:

    Instead of using Document.list(params) I used Document.findAll(). Is worth mentioning that in my application I do needed some kind of filter in my lists, so findAll() was the best approach. Anyways, here is how I would do it:

    Document.findAll( "from Document as d order by d." + params.sort + ' ' + params.order, params ) //supports pagination
    

    And in the View:

    <g:sortableCOlumn property="author.lastName" title=... />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

suppose you have two (or more) classes with private member vectors: class A {
Suppose I have two Classes, A and B. The A class is defined as
I have a Visual Studio solution with two projects: MyApp.MvcUI and MyApp.Domain (class library).
Suppose I have two methods in my class, methodA and methodB. In methodA, I
Suppose I have two classes: class A(): pass class B(): pass I have another
Suppose I have two classes a base class and an inherited class as follows:
Suppose I have two classes deriving from a third abstract class: public abstract class
Suppose I have User domain class and RegistrationCommand class. So when user is registering
Suppose I have two p tags in the document. I want to call two
Suppose I have two .NET DataTables populated as follows, where ID is the primary

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.