Grails 可排序列问题
Grails Sortable Column Issue
class Role implements Serializable {
// this is my domain class
private static final long serialVersionUID = 1
String authority
Role(String authority) {
this()
this.authority = authority
}
static constraints = {
authority blank: false, unique: true
}
static mapping = {
cache true
}
}
def indexList(){
render(template: "indexList", model:[roleInstanceList: Role.findAll()])
} // this is the method in the controller that renders the view page 'indexList'
<div class="col-md-12 main-header">Role List</div>
//this is my 'view' gsp page to be rendered
<table class="table manage-table">
<thead>
<tr>
**<g:sortableColumn property="authority"
title="${message(code: 'role.authority.label', default: 'authority')}" />**
</tr>
</thead>
<tbody>
<g:each in="${roleInstanceList}" status="i" var="roleInstance">
<tr id="${roleInstance.id}" class="${(i % 2) == 0 ? 'even' : 'odd'}">
<td>
${fieldValue(bean: roleInstance, field: "authority")}
</td>
</tr>
</g:each>
</tbody>
</table>
在这里,当我点击可排序列 'authority' - 排序没有完成,我得到了一个页面
使用以下 URL 刷新:role/indexList?sort=authority&order=asc
非常感谢任何帮助。
谢谢,请注意我是 grails 框架的新手
您可能需要 Role.list(params)
而不是 Role.findAll()
。
class Role implements Serializable {
// this is my domain class
private static final long serialVersionUID = 1
String authority
Role(String authority) {
this()
this.authority = authority
}
static constraints = {
authority blank: false, unique: true
}
static mapping = {
cache true
}
}
def indexList(){
render(template: "indexList", model:[roleInstanceList: Role.findAll()])
} // this is the method in the controller that renders the view page 'indexList'
<div class="col-md-12 main-header">Role List</div>
//this is my 'view' gsp page to be rendered
<table class="table manage-table">
<thead>
<tr>
**<g:sortableColumn property="authority"
title="${message(code: 'role.authority.label', default: 'authority')}" />**
</tr>
</thead>
<tbody>
<g:each in="${roleInstanceList}" status="i" var="roleInstance">
<tr id="${roleInstance.id}" class="${(i % 2) == 0 ? 'even' : 'odd'}">
<td>
${fieldValue(bean: roleInstance, field: "authority")}
</td>
</tr>
</g:each>
</tbody>
</table>
在这里,当我点击可排序列 'authority' - 排序没有完成,我得到了一个页面 使用以下 URL 刷新:role/indexList?sort=authority&order=asc 非常感谢任何帮助。 谢谢,请注意我是 grails 框架的新手
您可能需要 Role.list(params)
而不是 Role.findAll()
。