本文介绍了grails list.gsp / g:sortableColumn:能够对关联的域对象进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 字符串标题
字符串优先级
User assignedTo
...

我需要能够排序on assignedTo。 list.gsp默认脚手架和它使用的标签g:sortableColumn都不支持。看起来像g:sortableColumn需要同时拥有一个属性字段和一个propertyOfProperty字段。



你知道解决这个问题的好方法吗? b $ b

解决方案

好的,这似乎是可能的,只是缺少文档的清晰度,并且搜索网络并没有帮助。 b

因此,可以做property =assignedTo.lastName,即

 < g: sortableColumn property =assignedTo.lastNametitle =$ {message(code:'issue.assignedTo.label',default:'Assigned To')}/> 


Lets say I have an Issues domain class and it has as a field assignedTo:

String  title 
String  priority
User    assignedTo
  ...

I need to be able to sort on assignedTo. Neither the list.gsp default scaffolding nor the tag it uses, g:sortableColumn, support this. It seems like the g:sortableColumn needs to have both a property field, and a propertyOfProperty field.

Do you know a good way to solve this?

解决方案

Ok, so this appears possible, just missing clarity in the documentation, and searching the web didn't help.

So, one can do property="assignedTo.lastName", i.e.

 <g:sortableColumn property="assignedTo.lastName" title="${message(code: 'issue.assignedTo.label', default: 'Assigned To')}" />

这篇关于grails list.gsp / g:sortableColumn:能够对关联的域对象进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 16:25