grails自定义字段及其在生成索引视图中的显示顺序
我想自定义字段及其在生成的索引视图中的显示顺序 我的想法是创建一个名为indexFields的静态字段,它是我要在generated index.gsp中显示的字段的映射 在脚手架模板上有一个名为domainClass.persistentProperties的类grails自定义字段及其在生成索引视图中的显示顺序,grails,scaffolding,Grails,Scaffolding,我想自定义字段及其在生成的索引视图中的显示顺序 我的想法是创建一个名为indexFields的静态字段,它是我要在generated index.gsp中显示的字段的映射 在脚手架模板上有一个名为domainClass.persistentProperties的类 如何读取域类的静态属性?我设法找到了解决方案 在域中 静态索引列表=['number'、'carrier'、'validThrough'、'inUse'、'dateUsed'、'active'] 在index.gsp(脚手架模板)上阅
如何读取域类的静态属性?我设法找到了解决方案 在域中 静态索引列表=['number'、'carrier'、'validThrough'、'inUse'、'dateUsed'、'active'] 在index.gsp(脚手架模板)上阅读
def listFields=domainClass.getClazz()['indexList']
如果(列表字段){
allowedNames=列表字段
道具=[]
列表字段。每个{p->
propsOr您可以更改约束的顺序,因为这是它们在脚手架页面中的显示顺序。我已经尝试过了,但没有成功
def listFields = domainClass.getClazz()['indexList']
if(listFields){
allowedNames=listFields
props = []
listFields.each{p ->
props<<domainClass.getPropertyByName(p)
}
}else{
props = domainClass.properties.findAll { ...}
Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
}