我正在寻找一种简单的方法来使用脚手架在gorm模型中仅禁用一列的排序链接,但尚未找到任何与此相关的信息。

就像是

static constraints = {
    entryDate(nullable: false, blank: false, sortable: false)
}

在gorm中这可能吗?

最佳答案

您可以定义自己的属性并自定义脚手架模板。

自定义属性:

static constraints = {
    entryDate(nullable: false, blank: false, attributes: [sortable: false])
}

自定义脚手架模板可能如下所示:
props.eachWithIndex { p, i ->
cp = domainClass.constrainedProperties[p.name]
if (p.isAssociation() || (cp.attributes?.sortable != null && !cp.attributes.sortable) ) { %>

关于sorting - Grails Gorm禁止对脚手架中的字段进行排序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16077489/

10-10 17:22
查看更多