<f:table collection="personList"/>
<f:table collection="personList" properties="firstName, lastName"/>
<f:table collection="personList" properties="['firstName', 'lastName']"/>
<f:table collection="catsAndDogsList" domainClass="org.zoo.Animal"/>
<f:table collection="catsAndDogsList" domainClass="org.zoo.Animal" theme="bs-horizontal"/>
// List first three properties in Person
<f:table collection="personList" maxProperties="3"/>
// Include id, lastUpdated, dateCreated
<f:table collection="personList" except="[]]"/>
f:table
Purpose
<f:table/> renders some or all properties of a collection of beans in a table using the f:display widget for each property type. If there is no \_display template in scope the tag will simply render the property values.
Examples
The template for <f:table/> should be in
grails-app/views/templates/_fields/_table.gsp
but you can have multiple table templated, if you specify the template property.
All templates should still be located in view/templates/_fields/, the example below uses 4 different templates for table.
<f:table collection="myList" myProperty="Template: view/templates/_fields/_table.gsp" />
<f:table collection="${demoList}" template="table3" myProperty="Template: view/templates/_fields/_table3.gsp" />
<f:table collection="${demoList}" template="tables/table2" myProperty="Template: in view/templates/_fields/tables/_table2.gsp" />
<f:table collection="${demoList}" template="tables/table" myProperty="Template: view/templates/_fields/tables/_table.gsp" />
When theme is specified, the \_display template will be searched first in theme, but the theme property does not directly apply to table.
Attributes
| Name | Required? | Default | Description | 
|---|---|---|---|
collection  | 
yes  | 
The collection of beans to be displayed  | 
|
domainClass  | 
  | 
The FQN of the domain class of the elements in the collection.  | 
|
properties  | 
First 7 (or less)  | 
Comma-separated   | 
|
displayStyle  | 
Determines the display template used for the bean’s properties. Defaults to table meaning that \_display-table templates will be used when available.  | 
||
except  | 
  | 
A comma-separated   | 
|
order  | 
Comma-separated   | 
||
theme  | 
String  | 
Theme to use if available.  | 
|
maxProperties  | 
Number  | 
7  | 
The maximum number of properties to display when rendering the table. If zero is specified all columns are shown, otherwise   | 
template  | 
String  | 
'table'  | 
Alternative template for table rendering. Templates should be in the 'grails-app/views/templates/_fields/' folder.  | 
Any additional attributes are passed to the rendered template.
Modifying the _table.gsp template.
To make you own version of a f:table template, the file should be located in grails-app/views/templates/_fields/_table.gsp
unless a different location is specified with the template property.
You can find a starting point for a new file on GitHub
Model in the template
The following model is passed to the  _table.gsp template:
| Name | Content | 
|---|---|
domainClass  | 
The type of the persistent instance. Either type of the first row in the collection or the   | 
columnProperties  | 
Contains a list of   | 
domainProperties  | 
deprecated: see   | 
collection  | 
Rows with data  | 
displayStyle  | 
The attribute   | 
theme  | 
The attribute   | 
The column model:
| Name | Content | 
|---|---|
  | 
Empty instance of a   | 
  | 
The property name  | 
  | 
Deprecated, see   | 
  | 
The property type  | 
  | 
Translated label (deprecated)  | 
  | 
Translated label  | 
  | 
If the property has constraints  | 
  | 
Is the property required  | 
(This is a simplified version of a wrapper model)