views:

38

answers:

1

I have four entry fields from a search filter. I was originally using g:datePicker but it was not quite what I wanted, it was too slow to select the date from drop down boxes, so I decided it was better to use a simple grails text field and next to it a calendar image that would trigger the calendar. I was trying to use the YUI Calendar, from the YUI Plugin, but I couldn't make it work correctly when formatting the date.

Any ideas on how to do this??

Like if you think about it is just the calendar image next to the text field that triggers the calendar and puts the clicked date in the desired format in the text field, but for some reason is more complicated than that.

Thanks in advance!

A: 

I'm not quite sure I understand what your problem was with the YUI Plugin and date formatting. If you expand on that we might be able to help.

I would, however, recommend using the GrailsUI plugin which depends on the YUI plugin.

Install

grails install-plugin grails-ui

View

In your view make sure you include the appropriate components in your head section e.g.:

<head>
  ...
  <gui:resources components="datePicker"/>
  ...
</head>

Also change the <body> tag to <body class="yui-skin-sam"> if you want the default styles (skin) to apply.

Then you should be able to use:

<gui:datePicker id="myDateValue" value="${new Date()}" />

or if you want to set the format of the date:

<gui:datePicker id="myDateValue" formatString="yyyy/MM/dd HH:mm:ss" value="${new Date()}" />

Controller

When using the value from a datePicker in the controller, it should be treated as a string i.e.

Date.parse("yyyy/MM/dd HH:mm:ss", params.myDateValue)
Heinrich Filter
The thing is that I need the date in format ddMMMyy (13JUL10) and I tried doing it with Grails UI but they don't have that format :/ then I did some research in Google and YUI 2 has it. But I'm not sure how to implement YUI 2 with Grails :/ or a jscalendar that is triggered whenever a click an image next to the `g:textField` and puts the clicked date in the `g:textField` would do the job too, but I don't know how to do it
fgualda87