【发布时间】:2012-07-27 16:31:11
【问题描述】:
我在具有 Grails 2.0.3 版本的 Grails 项目中使用插件 JQGrid 3.8.0.1。
我有这个<jqgrid:grid> 有一个属性onSelectRow。我打算将我的重定向结构从表单结构转换为窗口结构。进行这种转换的原因是并非所有具有 JQGrid 组件的.gsp 文件在<body> 区域中都有<form> 组件。
从这里:
<jq:resources/>
<jqui:resources/>
<jqgrid:resources/>
<jqgrid:grid
// other main attributes (i.e., url, colNames, colModel, etc.)
onSelectRow="function(id) {
document.<formname>.action = 'view/' + id;
document.<formname>.submit();
}"></jqgrid:grid>
// html body content of form
<form name="<formname>">
</form>
到这里:
<jq:resources/>
<jqui:resources/>
<jqgrid:resources/>
<jqgrid:grid
// other main attributes (i.e., url, colNames, colModel, etc.)
onSelectRow ="function(id) {
window.location.href = ${createLink(action:'show', id:id)};
}"></jqgrid:grid>
jq、jqui、jqgrid标签是grails命令grails> install-plugin jquery jquery-ui jqgrid安装在项目上的插件
问题是新脚本不起作用。检查新的 html 源代码后,返回 onSelectRow 属性 window.location.href = /<Project Name>/<Controller>/show; 的值。问题是如何让 JQGrid 在新脚本上正常运行。
注意:我目前正在使用 Grails 的脚手架功能或
generate-all *命令
【问题讨论】:
-
您需要在createLink函数中定义控制器名称。
-
还是不行。即使没有定义控制器,Grails 也会返回一个默认的控制器名称,该名称是页面当前打包或位于
grails-app/view文件夹中的位置。
标签: grails redirect jqgrid grails-plugin grails-2.0