如何过滤AG:选择?
我是Grails和GSP的新手。我试图找到有关是否可能的文档 - 我发现了一个类似的问题,但无法成功应用它。
我有此G:选择语句:
<g:select name="users" multiple="multiple"
optionKey="id"
optionValue="name"
value="${user?.users*.id}"
from="${user.getUsers()}"
/>
我想知道是否可以向此添加过滤器或条件。我只能选择在某个国家(用户。国家)的用户。
I am new to Grails and gsp. I tried to find documentation on if this was possible - I found a similar question but was not able to successfully apply it.
I have this g:select statement:
<g:select name="users" multiple="multiple"
optionKey="id"
optionValue="name"
value="${user?.users*.id}"
from="${user.getUsers()}"
/>
I was wondering if it was possible to add a filter to this, or a condition. I can only select users that are in a certain country (users.country).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是。
看起来您在模型中具有
用户
属性,该对象是某些类的实例,该类别具有名为用户>的集合。
您的应用中的某些内容将
用户
放在模型中,可能是控制器操作。最佳实践是不要将很多逻辑嵌入GSP中,因此我建议控制器进行过滤,然后将合格对象放入单独的模型变量中,而GSP可以参考,而不是user.getusers()
,或者您可以创建一个自定义的GSP标签,该标签接受用户
并生成select
。It is.
It looks like you have a
user
property in the model and that object is an instance of some class that has a collection namedusers
.Something in your app is putting
user
in the model, likely a controller action. Best practice is to not embed much logic in a GSP so I would recommend either the controller do the filtering and put the qualifying objects in a separate model variable that the GSP can reference instead ofuser.getUsers()
, or you could create a custom GSP tag which accepts auser
and generates theselect
.