In index.gsp, I have this to redirect it to list.gsp, so I imagine there should be something like this:
${response.sendRedirect("entry/list")}
My filter is just one textField and two datePickers with drop-down lists (DD-MMM-YYYY) and they should be filtered by default from today to infinity. Therefore, he should show me only those events that have not yet occurred, but the old ones should still be in the database.
Here are links to my last 3 questions for reference.
I have a bunch of data and I need a data filter using Grails
Grails: filter data in a Grails table dynamically
Grails: edit and delete links do not work
I think the second is the one who has most of my code.
Any help would be greatly appreciated. Thank you! :) And once again, special thanks to proflux for all the help!
UPDATE
Here is the list on the .gsp list
<g:each in="${entryInstanceList}" status="i" var="entryInstance">
<tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
<td><g:formatDate format="dd-MMMM-yyyy" date="${entryInstance.fechaCambio}" /></td>
<td><b>${fieldValue(bean: entryInstance, field: 'proyectoRuta')}</b></td>
<td>${fieldValue(bean: entryInstance, field: 'summary')}</td>
<td><g:formatDate format="dd-MMM-yyyy HH:mm z" date="${entryInstance.lastUpdated}" /></td>
<td>
<g:form>
<g:hiddenField name="id" value="${entryInstance?.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>
UPDATE
Here is the searchResults code,
def searchResults = {
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", 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':'', 'lastUpdatedH':params?.lastUpdatedH])
}
And since I already use the results and the list, what should I do, give it a different name and in the end put it on the model after the results? as:
render(view:'searchResults', model:['results':results, 'otherResults':otherResults, 'proyectoRutaN':params?.proyectoRutaN, 'fechaCambioD':params?.fechaCambioD, 'fechaCambioH':params?.fechaCambioH, 'lastUpdatedD':'', 'lastUpdatedH':params?.lastUpdatedH])
Or do I just need to define it inside the results?
UPDATE
<table><tbody class="yui-skin-sam">
<tr class="prop">
<td valign="top" class="name"><b>Proyecto/Ruta: </b> <g:textField name="proyectoRutaN" value="${proyectoRutaN}" /></td>
<td></td>
<td valign="top" class="name"><b>Fecha de Implementación: </b></td>
<td></td>
<td valign="top" class="name"><b>Fecha de Última Modificación: </b></td>
</tr>
<tr class="prop">
<td></td>
<td valign="top">Desde:</td>
<td valign="top"><gui:datePicker name="fechaCambioD" value="${params?.fechaCambioD}" formatString="dd/MMM/yyyy"/></td>
<td valign="top">Desde:</td>
<td valign="top"><gui:datePicker name="lastUpdatedD" value="${params?.lastUpdatedD}" default="none"/></td>
</tr>
<tr class="prop">
<td></td>
<td valign="top">Hasta:</td>
<td valign="top"><gui:datePicker name="fechaCambioH" value="${params?.fechaCambioH}" formatString="dd/MMM/yyyy"/></td>
<td valign="top">Hasta:</td>
<td valign="top"><gui:datePicker name="lastUpdatedH" value="${params?.lastUpdatedH}" default="none"/></td>
</tr>
For some reason, when I apply filters, it shows me everything in the list (it does not filter), and the text fields in the filter do not save the date from the moment the filter was applied.
Any ideas on how I can fix this?