0
有沒有支持非select的數據綁定的標籤? 。我用它的一對多關係Grails:支持數據綁定的標籤?
似乎不切實際,如果你有大量的數據和滾動會更長
這將是真棒,如果它只是一個複選框列表,然後會有一個分頁
有沒有支持非select的數據綁定的標籤? 。我用它的一對多關係Grails:支持數據綁定的標籤?
似乎不切實際,如果你有大量的數據和滾動會更長
這將是真棒,如果它只是一個複選框列表,然後會有一個分頁
g.select
只是Grails默認值,但您可以自定義視圖並使用任何元素,因爲信息在那裏。例如:
class Parent {
String name
static hasMany = [childrens: Child]
}
class Child {
String name
}
class ParentController {
def create() {
Parent parentInstance = new Parent()
List<Children> childrens = Children.list()
[parentInstance : parentInstance, childrens: childrens]
}
def save() {
def childrens = params.list('childrens')
println childrens //will output all checkbox marked...
}
}
form.gsp
<ul>
<g:each in="${childrens}" var="child">
<li><g:checkBox name="childrens" value="${child in parentInstance.childrens}" /></li>
</g:each>
</ul>
一些關鍵點的位置:
hasMany
側可以有很多的記錄;相關主題:Grails - Simple hasMany Problem - Using CheckBoxes rather than HTML Select in create.gsp