sorting - Grails Gorm禁止对脚手架中的字段进行排序

标签 sorting grails gorm

我正在寻找一种简单的方法来使用脚手架在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/

相关文章:

grails - Grails Ajax标签已弃用

grails - Grails GORM默认排序字段,它也是组合键的字段

javascript - 使用odata模型显示之前对sap ui5表进行排序

grails - 2.0.0.RC1 Where Queries - No such property 异常

mysql - 获取一组数据的最新条目

sql - SQL对Hql查询进行非常大的关联

grails - Grails/GORM:映射这两个域的正确/最佳方法是什么?

grails - 当hasMany没有任何元素时,选择Grails条件

perl:洗牌值排序哈希?

c - 使用指针和两个结构数组进行桶排序