I have a table, with a series of events, name of my class is Entry.
Here is a picture of my table
is in Spanish, but the basics are the same so it shouldn't be a problem. (the filter HTML code is not yet so its a mess but it works)
and here are the results that I get when I look for the entry.
Now my problem is that I need the results to be shown/filtered into the same table from pic1, so it would be basically like a table update applying the filters.
If you need more info here is the link to my old question. Thanks proflux!
Most of the search code is there,
Any help would be greatly appreciated! -Fernando
UPDATE:
I have a problem filtering the dates though... I have two dates... One is the date the event is going to take place, and the other one is lastUpdated which I think is a keyword for grails for the last time you modified the Event. Any help related to filtering dates would be greatly appreciated.
I need to show everything on the first table starting from today's date. And if I want to find something from the past I should be able to use the filter to find it.
Any ideas on how to do this?
IPDATE:
So here is my list.gsp
and here is my searchResults.gsp with the filters applied for the word "Ruta"
So basically everything looks nice and pretty but the date filters are not working.
Here is the code in the controller that is not filtering the dates
def searchResults = {
def entryCriteria = Entry.createCriteria()
def results = entryCriteria.list {
if(params?.proyectoRuta) {
ilike("proyectoRuta","%${params.proyectoRuta}%")
}
}
if(params?.day) {
eq("fechaCambio", params.day)
}
render(view:'searchResults', model:['results':results])
}
is filtering the word but not the dates
proyectoRuta
would be the title and fechaCambio
would be the date shown in the first column. I have not tried to filter the lastUpdated date yet.
UPDATE:
Ok so here is my controller: Since is a lot of code I will only post the important defs
def search = {
render(view:'search')
}
def searchResults = {
def entryCriteria = Entry.createCriteria()
def results = entryCriteria.list {
if(params?.fechaCambioD && params?.fechaCambioH) {
between("fechaCambio", params.fechaCambioD, params.fechaCambioH)
}
if(params?.lastUpdatedD && params?.lastUpdatedH) {
between("lastUpdated", params.lastUpdatedD, params.lastUpdatedH)
}
if(params?.proyectoRutaN) {
ilike("proyectoRuta","%${params.proyectoRutaN}%")
}
}
render(view:'searchResults', model:['results':results, 'proyectoRutaN':params?.proyectoRutaN, 'fechaCambioD':params?.fechaCambioD, 'fechaCambioH':params?.fechaCambioH, 'lastUpdatedD':params?.lastUpdatedD, 'lastUpdatedH':params?.lastUpdatedH])
}
}
And here is the searchResults.gsp
<tbody>
<g:each in="${results}">
<td><g:formatDate format="dd-MMMM-yyyy" date="${it.fechaCambio}" /></td>
<td><b>${it.proyectoRuta}</b></td>
<td>${it.summary}</td>
<td><g:formatDate format="dd-MMM-yyyy HH:mm z" date="${it.lastUpdated}" /></td>
<td>
<g:form>
<g:hiddenField name="id" value="${it?.id}" />
<span class="simple"><g:actionSubmit class="editar" action="edit" value="${message(code: 'default.button.editar.label', default: ' ')}" /></span>
<span class="simple"><g:actionSubmit class="eliminar" action="delete" value="${message(code: 'default.button.eliminar.label', default: ' ')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Esta seguro que desea Eliminar?')}');" /></span>
</g:form>
</td>
</tr>
</g:each>
</tbody>