Search code examples
templatesgrailsscaffolding

Define table headers in Grails domain class for view generation


I want to be able to define view table headers in domain classes. I thought about creating a transient property called inTable and then iterate through its values in scaffolding template. Here is a transient property:

List inTable=['cardId','fullName','dateOfBirth','sex','bloodGroup','civilStatus','status']

Now How can I get inTable values inside my scaffolding template?


Solution

    1. Make it a static field of your domain class.

    2. Take a look at the way regular scaffolding iterates the class properties. (run grails install-templates if you haven't yet)

    3. Access domainClass.getClazz().inTable.