g:具有复杂关联的sortableColumn

时间:2014-03-24 19:32:00

标签: grails gsp grails-2.3

所以我试图对一个对象表(Deliverables)进行排序。我想为每个标题使用g:sortableColumn(客户端,项目,可交付成果)。目前我正在尝试实施此博客http://sguthula.blogspot.com/2011/05/implementing-advanced-search-in-grails.html中找到的解决方案,但没有成功。

我的协会的一个例子如下:

class Deliverable {
    static belongsTo = [project: Project]
}

class Project {
    Client client
    static hasMany = [deliverables: Deliverable]
}

class Client {
    String name
    static hasMany = [projects: Project]
}

在我的表格中,我试图按客户名称订购。

<g:sortableColumn property="name" title="${message(code: 'deliverable.project.client.name.label', default: 'Client')}"></g:sortableColumn>

这是一个比较复杂的关联,但即使我尝试按project.name排序,也会导致每个项目的可交付成果被重新排序,而不是整个列表根据客户端或项目名称重新排序。 / p>

为所提供的任何帮助干杯。

1 个答案:

答案 0 :(得分:1)

请您在浏览器上查看和发布检查结果,如

1. goto inspect window and network

2. press the `g:sortablecolumn` and see if anything is posted or a request ? 

3. if yes , that is how i can resolve this issue and you should to ..see which 
   object/parameteris passed to 
   the controller so that you can play with the code.

4.if not Syntax error please first try with simple settings and correct 
    to see how it   works on 1,2,3 steps.
欢呼你肯定会找到解决方案!!