2011-09-08 70 views
0

我想创建一个包含多个表的gsp页面。 请注意,术语“表”我的意思是图形表(标签)而不是数据库表。 表格应具有可排序标题为每个gsp页面呈现多个可排序表格?

如果一个gsp页面只包含一个表格,可以很容易地使用现有的sortableColumn和paginate标签。 它们将相关条目插入“参数”映射(例如“sort = column4711”)。 但是,如果在页面上涉及多个图形表,这并不容易。 问题是相关控制器不知道哪个表的参数与 相关联(即,如果存在映射条目“sort = column4711”,则控制器不知道它属于哪个表)。

我目前思考下面的解决方案,我认为相当难看的:

<div class="list"> 
       <table> 
        <thead> 
         <tr> 

          <g:sortableColumn property="id" title="${message(code: 'user.id.label', default: 'Id')}" /> 

          <g:sortableColumn property="password" title="${message(code: 'user.password.label', default: 'Password')}" /> 

          <g:sortableColumn property="userId" title="${message(code: 'user.userId.label', default: 'User Id')}" /> 

          <g:sortableColumn property="userName" title="${message(code: 'user.userName.label', default: 'User Name')}" /> 


          <g:sortableColumn property="id" title="${message(code: 'bookDetails.id.label', default: 'Id')}" /> 

          <th><g:message code="bookDetails.bookId.label" default="Book Id" /></th> 

          <g:sortableColumn property="pages" title="${message(code: 'bookDetails.pages.label', default: 'Pages')}" /> 

          <g:sortableColumn property="price" title="${message(code: 'bookDetails.price.label', default: 'Price')}" /> 



          <g:sortableColumn property="id" title="${message(code: 'book.id.label', default: 'Id')}" /> 

          <g:sortableColumn property="author" title="${message(code: 'book.author.label', default: 'Author')}" /> 

          <g:sortableColumn property="bookId" title="${message(code: 'book.bookId.label', default: 'Book Id')}" /> 

          <g:sortableColumn property="bookName" title="${message(code: 'book.bookName.label', default: 'Book Name')}" /> 

          <g:sortableColumn property="category" title="${message(code: 'book.category.label', default: 'Category')}" /> 

         </tr> 

        </thead> 
        <tbody> 
        <g:each in="${userInstanceList}" status="i" var="userInstance"> 
         <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 

          <td><g:link action="show" id="${userInstance.id}">${fieldValue(bean: userInstance, field: "id")}</g:link></td> 

          <td>${fieldValue(bean: userInstance, field: "password")}</td> 

          <td>${fieldValue(bean: userInstance, field: "userId")}</td> 

          <td>${fieldValue(bean: userInstance, field: "userName")}</td> 

         </tr> 
        </g:each> 

        <g:each in="${bookDetailsInstanceList}" status="i" var="bookDetailsInstance"> 
         <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 

          <td><g:link action="show" id="${bookDetailsInstance.id}">${fieldValue(bean: bookDetailsInstance, field: "id")}</g:link></td> 

          <td>${fieldValue(bean: bookDetailsInstance, field: "bookId")}</td> 

          <td>${fieldValue(bean: bookDetailsInstance, field: "pages")}</td> 

          <td>${fieldValue(bean: bookDetailsInstance, field: "price")}</td> 

         </tr> 
          </g:each> 

        <g:each in="${bookInstanceList}" status="i" var="bookInstance"> 
         <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 

          <td><g:link action="show" id="${bookInstance.id}">${fieldValue(bean: bookInstance, field: "id")}</g:link></td> 

          <td>${fieldValue(bean: bookInstance, field: "author")}</td> 

          <td>${fieldValue(bean: bookInstance, field: "bookId")}</td> 

          <td>${fieldValue(bean: bookInstance, field: "bookName")}</td> 

          <td>${fieldValue(bean: bookInstance, field: "category")}</td> 

         </tr> 
        </g:each> 




        </tbody> 
       </table> 
      </div> 

     </div> 
    <body> 

所以请指导我们解决问题

回答

0

有一个远程分页插件。它有一些我必须解决的问题,但我没有修改它的版本(并且从我使用它开始已经有一段时间了)。基本上它会进行Ajax调用而不是渲染整个页面。你得到remoteSortableColumn和remotePaginate的标签