简体   繁体   中英

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>

Here, when I click on Sortable Column 'authority' - sorting is not done and I am getting a page refresh with the following URL: role/indexList?sort=authority&order=asc Any help much appreciated. Thanks and a note to point that I am new to grails framework

您可能需要Role.list(params)而不是Role.findAll()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM