我试图通过一个remoteFunction传递一个g:datePicker值,但是它返回一个空值。有人知道如何解决这个问题吗?
我的GSP页面:
<%@ page contentType="text/html;charset=ISO-8859-1" %>
<html>
<g:javascript library="jQuery"/>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<meta name="layout" content="main"/>
<title>Insert title here</title>
</head>
<body>
<form action="">
<table>
<tr>
<td>Select Category :</td>
<td><g:select name="category"
from="['Crop','Location','Pest and Disease']"
onchange="${remoteFunction(controller:'AG10_aggregationReport',
action:'view', update:'report',
params:'\'filter=\'+document.getElementById(\'req_date\').value' )};"/>
</td>
<td>Date :</td>
<td><g:datePicker name="req_date" id="req_date" value=""/></td>
<td><g:submitButton name="view" value="View"/></td>
</tr>
<tr>
<td></td>
</tr>
</table>
<div id="report"></div>
</form>
</body>
</html>
最佳答案
通常,grails期望字段名称为:
${fieldName}_year, ${fieldName}_month, ${fieldName}_day
一个名为
${fieldName}
的隐藏字段,其中包含值“date.struct”。然后,当它在后端遇到
'date.struct'
时,它将为您解析数据。当您从req_date
中获取值时,您将获得'date.struct'
,这显然不是日期。您可以在此处阅读一些解决方法:Grails Date property editor
http://www.dariopardo.com/grails/jquerydatepickergrailstag/
关于jquery - 如何通过remoteFunction传递g:datePicker值?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12242764/