我已经完成的步骤:
mavenRepo "http://repo.grails.org/grails/core"
添加到BuildConfig.groovy中的存储库compile ":easygrid:1.7.1"
添加到BuildConfig.groovy中的插件String firstname
和String lastname
def index() { }
添加 Controller com.test.HomeController views/home/index.gsp
接下来,我在com.test.HomeController中添加了以下内容:
def authorJQGrid = {
domainClass Author
gridImpl 'jqgrid'
jqgrid {
sortname 'firstname'
}
export {
export_title 'Author'
pdf {
'border.color' java.awt.Color.BLUE
}
}
columns {
firstname
lastname
}
}
并将以下内容添加到home / index.gsp:
<!DOCTYPE html>
<html>
<head>
<asset:javascript src="easygrid.jqgrid.js"/>
<asset:stylesheet src="easygrid.jqgrid.css"/>
</head>
<body>
<grid:grid id='jqgridinitial' name='authorJQGrid'>
<grid:set width="900" caption="Authors"/>
</grid:grid>
<grid:exportButton name='authorJQGrid'/>
</body>
</html>
编译时,出现以下错误:
Could not process the EasygridConfig file
当我尝试转到网页时,出现以下错误:
[http-bio-8080-exec-9]错误error.GrailsExceptionResolver-处理请求:[GET] / website / home /时发生NullPointerException
无法在空对象上获取属性'authorJQGrid'。 Stacktrace如下:
消息:错误处理GroovyPageView:错误执行标签:无法在空对象上获取属性'authorJQGrid'
我该怎么做才能使JQGrid工作?
最佳答案
为了使用插件EasyGrid,必须使用@Easygrid注释 Controller (定义网格的位置)。
以下示例是从https://github.com/tudor-malene/grails-petclinic/blob/master/grails-app/controllers/org/grails/samples/OverviewController.groovy中提取的,显示了一个示例:
@Easygrid
class OverviewController {
def ownersGrid = {
domainClass Owner
columns {
id {
type 'id'
enableFilter false
}
firstName
lastName
address
city
telephone
nrPets {
enableFilter false
value { owner ->
owner.pets.size()
}
jqgrid {
sortable false
}
}
}
}
}
关于grails - Grails 2.5.0-在全新的Grails安装上设置JQGrid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31483072/