我使用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