问题描述
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>
在这里,当我单击“可排序列”“权限”时-排序未完成,正在获取页面 使用以下URL刷新: role / indexList?sort = authority&order = asc 任何帮助,不胜感激。 谢谢,并指出我是grails框架的新手
解决方法
您可能希望使用Role.list(params)
而不是Role.findAll()
。