I was using regular datePicker from grails but I decided it was easier to use a textField with a calendar next to it and I was recommended to use Grails-UI.
My problem is that now, when I click to apply the filters, they do not work. Somehow they are not being recognized.
Any help would be greatly appreciated.
Here is the code for the controller:
def searchResults = {
def fromCal
if(params?.lastUpdatedD) {
fromCal = Calendar.getInstance()
fromCal.setTime(params?.lastUpdatedD)
fromCal.set(Calendar.HOUR_OF_DAY,0)
fromCal.set(Calendar.MINUTE,0)
fromCal.set(Calendar.SECOND,0)
fromCal.set(Calendar.MILLISECOND,0)
}
def toCal
if(params?.lastUpdatedH) {
toCal = Calendar.getInstance()
toCal.setTime(params?.lastUpdatedH)
toCal.set(Calendar.HOUR_OF_DAY,23)
toCal.set(Calendar.MINUTE,59)
toCal.set(Calendar.SECOND,59)
toCal.set(Calendar.MILLISECOND,999)
}
def entryCriteria = Entry.createCriteria()
def results = entryCriteria.list {
and{if(params?.fechaCambioD && params?.fechaCambioH) {
between("fechaCambio", params.fechaCambioD, params.fechaCambioH)
}
if(params?.lastUpdatedD && params?.lastUpdatedH) {
between("lastUpdated", fromCal.getTime(), toCal.getTime())
}
if(params?.proyectoRutaN) {
ilike("proyectoRuta","%${params.proyectoRutaN}%")
}
}
}
render(view:'searchResults', model:['results':results, 'proyectoRutaN':params?.proyectoRutaN, 'fechaCambioD':params?.fechaCambioD, 'fechaCambioH':params?.fechaCambioH, 'lastUpdatedD':'', 'lastUpdatedH':params?.lastUpdatedH])
And here is a piece of code in the search.gsp where the gui:datePicker is declared
<gui:datePicker name="fechaCambioH" value="${params?.fechaCambioH}" formatString="dd/MMM/yyyy"/>
If I change them to <<gui:datePicker name="fechaCambioH" value="${params?.fechaCambioH}" precision="day" default="none" noSelection="['':'']" years="${2010..2015}"/>/>
it works perfectly fine but it gives me 3 drop down boxes for day month and year, and the idea is to use just one textField with a calendar next to it to help it look nicer.
Thanks in advance
UPDATE
Here is the code I have in the list.gsp
def list = {
params.max = Math.min(params.max ? params.int('max') : 10, 100)
[entryInstanceList: Entry.list(params), entryInstanceTotal: Entry.count()]
def today = Calendar.getInstance()
today.setTime(new Date())
today.set(Calendar.HOUR_OF_DAY, 0)
today.set(Calendar.MINUTE, 0)
today.set(Calendar.SECOND, 0)
today.set(Calendar.MILLISECOND, 0)
def results = Entry.findAllByFechaCambioGreaterThanEquals(today.getTime())
render(view:'list', model:['entryInstanceList':results])
So I wanted to know if I could do the same to sort the things that were filtered. Because now when I click on the title of each column, after being filtered, it orders every single item from the list. If I do it whenever I create new entries, it orders them from today on (only the things that you are seeing), but when I apply a filter and then order it sorts every single item on the list, not just what it being showed.
I think it sounds a little confusing, I hope you can help.
Thanks in advance!