Search code examples
sortinggrailsgrails-orm

Grails Gorm Disable Sorting for a Field in Scaffolding


I am looking for an easy way to disable the sorting link for just one column in a gorm model using scaffolding, but have not found anything to this regard.

something like

static constraints = {
    entryDate(nullable: false, blank: false, sortable: false)
}

is this possible in gorm?


Solution

  • You can define your own attributes and customize the scaffolding-templates.

    Custom attributes:

    static constraints = {
        entryDate(nullable: false, blank: false, attributes: [sortable: false])
    }
    

    Customizing the scaffolding-template could look like this:

    props.eachWithIndex { p, i ->
    cp = domainClass.constrainedProperties[p.name]
    if (p.isAssociation() || (cp.attributes?.sortable != null && !cp.attributes.sortable) ) { %>