grails - Grails 2.5.0-在全新的Grails安装上设置JQGrid

标签 grails jqgrid

我已经完成的步骤:

  • 创建新项目
  • mavenRepo "http://repo.grails.org/grails/core"添加到BuildConfig.groovy中的存储库
  • compile ":easygrid:1.7.1"添加到BuildConfig.groovy中的插件
  • 将域类com.test.Author添加到String firstnameString 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/

    相关文章:

    javascript - Jquery:表内行的内联编辑

    javascript - 如何将 "All"项放入搜索工具栏的选择菜单中?

    javascript - 如何在内联编辑中更新其他列更改的列

    xml - 定义XML数据源,并在引导阶段将其导入到grails应用中

    java - 如何配置 grails 在生成 war 时保留 grails.app.context 变量?

    grails - 如何记录用户访问的站点

    hibernate - MongoDB和Hibernate GORM之间的级联差异

    jquery - 如何从 JqGrid 中单元格的自定义格式化程序访问其他行数据

    javascript - jqGrid 中的 onCellSelect 设置出现问题

    grails 3 gsp 使用域对象约束失败