我使用G:sortableColumn我的表,但我得到这个错误:G:sortableColumn缺少控制器的名称(我如何可以通过控制器的名字?G:sortableColumn)
通过UrlMappingException引起:无法为映射 [/()/()?/(*)?]和参数[{sort = firstName,order = asc, action = list}]创建URL。参数[控制器]是必需的,但不是指定的 !
这是我的代码:
<g:sortableColumn property="firstName" title="FirstName"/>
这是我的课:
package medicalautomation
class InformationDocs {
String firstName
String lastName
String idNum
String sex
String bloodType
Date birthDay
String job
String backGround
Double weight
Double height
Double bloodPressure
Double bloogSugar
String phoneNum
String address
String description
static constraints = {
firstName()
lastName()
idNum()
sex()
bloodType()
birthDay()
job()
backGround(maxSize:5000)
weight(nullable: true)
height(nullable: true)
bloodPressure(nullable: true)
bloogSugar(nullable: true)
phoneNum(maxSize: 20)
address(maxSize: 200)
description(maxSize: 5000)
}
}
那么其明显的是,当我使用它在另一个GSP页面一个比它是链接到控制器,我必须通过控制器名称。问题是我不知道如何,我不确定它是否与URL映射有关。
感谢您的帮助
我的GSP代码:
<!doctype html>
<html>
<head>
<meta name="layout" content="main"/>
<g:javascript library="jquery" plugin="jquery" />
<title>Welcome to Grails</title>
</head>
<body>
<div class="topnav">
<p style="color: white">Top Nav</p>
</div>
<div class="sidenav">
<div class="sidenavcontent" >
<h1>HELLO!!!</h1>
<ul>
<g:each var="c" in="${grailsApplication.controllerClasses.sort { it.fullName } }">
<li><g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link></li>
</g:each>
</ul>
<table>
<tr>
<g:sortableColumn property="firstName" title="FirstName"/>
<g:sortableColumn property="lastName" title="LastName"/>
<g:sortableColumn property="idNum" title="ID Number"/>
</tr>
<g:each in="${medicalautomation.InformationDocs.list()}" var="info">
<tr>
<td><g:remoteLink id="${info.id}" controller="informationDocs" action="show" update="showdetails">${info.firstName}</g:remoteLink></td>
<td>${info.lastName}</td>
<td>${info.idNum}</td>
</tr>
</g:each>
</table>
</div>
</div>
<div class="bodycont">
<div id="showdetails"></div>
</div>
我使用PARAMS地图发送控制器并正确调用名单行动但有是一个问题:
我改名单的行动,并将其重定向到GSP页面,G:sortableColumn是,但它似乎是表的顺序不changing.This是我的代码在控制器:redirect(uri: "?sort=${params.sort}&order=${params.order}")
你可以把你的GSP代码放在你使用** sortableColumn **的地方以便更好的理解。 –
@ajaypanchal我更新了文章 – Navid
尝试在
Vahid