grailsgsp

How can I make grails show me all columns/fields from the domain in the list-view


I've search all evening to find a solution but the few I found does not stick with the newer version of grails that I use.

I know that it was limited to 6 fields before but now I can see 7. But I need a lot more columns, no matter that the page will be cluttered.

I have also checked the code that the f:table tag constructs and can not see that there is any limitation there.

I do not know what to do, I need to have this application ready tomorrow morning so I'm desperate finding a solution. Please help..

I use GRAILS-3.2.3. I can take any domain just it have more than 7 fields the 8th and upwards will not be displayed.

I use the grails command: ("generate-all" domain) to create controllers and views. And without doing anything more I get this problem. Therefore I didn't think I needed to bring any code to show - anyone trying to this should get the same problem.

Below is the template for index.gsp -- Can anyone explain where the limitation of number of columns is made here?

<!DOCTYPE html>
<html>
    <head>
        <meta name="layout" content="main" />
        <g:set var="entityName" value="\${message(code: '${propertyName}.label', default: '${className}')}" />
        <title><g:message code="default.list.label" args="[entityName]" /></title>
    </head>
    <body>
        <a href="#list-${propertyName}" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
        <div class="nav" role="navigation">
            <ul>
                <li><a class="home" href="\${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
                <li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
            </ul>
        </div>
        <div id="list-${propertyName}" class="content scaffold-list" role="main">
            <h1><g:message code="default.list.label" args="[entityName]" /></h1>
            <g:if test="\${flash.message}">
                <div class="message" role="status">\${flash.message}</div>
            </g:if>
            <f:table collection="\${${propertyName}List}" />

            <div class="pagination">
                <g:paginate total="\${${propertyName}Count ?: 0}" />
            </div>
        </div>
    </body>
</html>

I've made my last trial tonight, I'll continue tomorrow morning again because I think I need to hard code everything to get ready. It was a nice advice to have a look at that "Anorak-Girl" report, but the source of the f:table-tag didn't show any limitation - so where can it be? Thanks a lot but there's still a lot to do....I'll come back and good night.

Below is the code of _table.gsp or f:table-tag.

<table>
    <thead>
         <tr>
            <g:each in="${domainProperties}" var="p" status="i">
                <g:set var="propTitle">${domainClass.propertyName}.${p.name}.label</g:set>
                <g:sortableColumn property="${p.name}" title="${message(code: propTitle, default: p.naturalName)}" />
            </g:each>
        </tr>
    </thead>
    <tbody>
        <g:each in="${collection}" var="bean" status="i">
            <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
                <g:each in="${domainProperties}" var="p" status="j">
                    <g:if test="${j==0}">
                        <td><g:link method="GET" resource="${bean}"><f:display bean="${bean}" property="${p.name}" displayStyle="${displayStyle?:'table'}" /></g:link></td>
                    </g:if>
                    <g:else>
                        <td><f:display bean="${bean}" property="${p.name}"  displayStyle="${displayStyle?:'table'}" /></td>
                    </g:else>
                </g:each>
            </tr>
        </g:each>
    </tbody>
</table>

Solution

  • possibly a limitation around f:table. Having had a look around: http://blog.anorakgirl.co.uk/2016/01/what-the-f-is-ftable/

    Finally… how to customise the f:table tag:

    Place a file called _table.gsp in /grails-app/views/templates/_fields/


    To do this manually:

    An example and here you can iterate through your own property manually.

    so in your case

    <g:each in="\${${propertyName}List}" var="myDom">
      <tr><td>${myDom.id}</td><td>${myDom.name}</td><td>and so on</td></tr>
    </g:each>