开发者

Groovy: Sorting Columns in a view: list

I have a Groovy application. I am rendering the view list using the following statement:

render (view: 'list', model:[reportingInsta开发者_如何学GonceList: reportingInstanceList, reportingInstanceTotal: i, params: params]) 

The list.gsp is as follows:

The view is rendered but the default sorting is not working.

<g:sortableColumn class="tabtitle" property="id" title="Id" titleKey="reporting.id" />
<g:sortableColumn class="tabtitle" property="company" title="Company" titleKey="reporting.company" />

Unfortunately the default sorting (by id, by company, etc) are not working. Any hint why?

Thanks a lot in advance.

Luis


If you are asking about the sorting/order links at the top of the columns on the list page, the links are hrefs back to the controller and method that was originally used to populate the list. Plus the URLs include parameters for sort and order. For instance:

/tracker/bug/searchCurrentUserProject?sort=name&order=asc

The controller method will then need to handle the sort and order values from the link:

params.sort = params.sort ?: "priority"

params.order = params.order ?: "asc"

And pass them to the database query:

def bugList = Bug.createCriteria().list( sort:params.sort, order:params.order, max:params.max, offset:params.offset) { eq "projectId", new Integer (params.projectId) }


You can add two hidden fields in your form, set them dynamically with Javascript and send them together with your form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜