Grails 复选框处理
比方说,我有这样的场景:
但是比方说我有数百个这样的复选框,我需要这些复选框提交表格后同时处理所有事情。然后,我需要根据选中的框以及每个块的 id 将一些内容保存到 BD
所以,我需要这个:
a)一种知道选中了数百个复选框的方法 b) 每个复选框都应该与我要传递的 ID '链接',以便执行特定操作。
我有一个
标签向我写入整个表,从数据库读取值。我将不胜感激任何帮助, 提前致谢,RR
Let's say, i have this scenerio:
But let's say i have hundreds of those checkBoxes, which i need to handle everything at same time after submiting a form. I then will need to save to the BD something based on which boxes are checked, and the id of each block
So, i need this:
a) a way to know which checkboxes are checked, within hundreds of them
b) each checkbox should be 'linked' with an id which im gona pass, so that a specific action will be performed.
I have a <g:each>
tag writing me the whole table, reading values from the DB. I would appreciate any help with this,
Thanks in advanced, RR
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将参数绑定到域对象或命令对象的 List 属性。
视图:
命令对象:
控制器:
You can bind the params to a List property of a domain object or command object.
View:
Command Object:
Controller:
在您的 gsp 中,您需要显示所有复选框:
在控制器操作中,您需要将选定的复选框映射到您的域对象
}
In your gsp you need to display all the checkboxes:
In the controller action you need to map the selected checkboxes to your domain objects
}