Reputation: 157
I'm using g:sortableColumn for my table but I get this error :
Caused by UrlMappingException: Unable to create URL for mapping [/()/()?/(*)?] and parameters [{sort=firstName, order=asc, action=list}]. Parameter [controller] is required, but was not specified!
This is my code:
<g:sortableColumn property="firstName" title="FirstName"/>
And this is my class:
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)
}
}
Well its obvious that when I use it in another GSP page than the one in which it is linked to the controller, I have to pass the controller name.The problem is I don't know how ,and I'm not sure if it has anything to do with URL mapping.
Thanks for your help
My GSP code:
<!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>
I send the controller using params map and it calls the list action correctly but there is a problem :
I changed the list action and it redirects to the gsp page that g:sortableColumn is but it seems that the order of the table is not changing.This is my code in controller:redirect(uri: "?sort=${params.sort}&order=${params.order}")
Upvotes: 1
Views: 327
Reputation: 493
As I understand you correctly, the gsp-page is not the views -> medicalautomation.informationDocs.index one?
... if you would redirect the sortable-column to a different controller, you have to take the responsibility, to provide the same data as the list-method for this controller who displays initially the gsp-page and have to specify this gsp-page in the response ... (because after clicking the sortable-column, the same page is displayed again, with the list, sorted by the column-name)
and therefore, your
<g:each in="${medicalautomation.InformationDocs.list()}" var="info">
confuses me a bit, because there you call the DomainClass-list method directly without the params (where the sort-order is specified) and I think your sort-order would get discarded, even if you managed it to display it without the exception...?
In cases, where the depending list, which I want to display, is limited, I often use jQuery-DataTable. Which has a the possibility to sort the lines etc. builtin.
And:
In cases where I want to display a small collection of depending data, I usually use a jQuery.ajax call to get the data and modify the html through jQuery/Javascript ...
Hope I could help a bit.
Upvotes: 1