|
This questions seem to be repeated. But sorry for that, as a newbie to Grails development, I'm getting worried with using paginate tag!.
Here is what I want, I need to query all Tasks for a particular project! So I came up writing this action : def listMyProject(){ def proj = params.managersProject def project = Project.findByName("$proj") def taskPagedResult = Tasks.createCriteria().list(max: params.max as Integer, offset: params.offset as Integer) { eq('project', project) } [tasksInstanceList: taskPagedResult, tasksInstanceTotal: taskPagedResult.getTotalCount()] } My view file is : <%@ page import="mnm.schedule.Tasks" %> <!doctype html> <html> <head> <meta name="layout" content="main"> </head> <body> <div id="list-tasks" class="content scaffold-list" role="main"> Results
<g:paginate total="${tasksInstanceTotal}" controller="project" action = "listMyProject" /> </div> </div> </body> </html> This is not working properly. First I get the page where I can see the first 10 results, with next and button appearing. But when I click on the next button, I didn't see anything! I can see only the table been rendering without the contents of it. After that when I click on previous button, I get the same effect, only table been rendered. I'm a newbie to Grails, I'm with this problem for past two days! Please kindly help me!
Ant's
|
|
It looks like you're loosing managersProject. Add it to the params you
pass to your view: [tasksInstanceList: taskPagedResult, tasksInstanceTotal: taskPagedResult.getTotalCount(), managersProject:managersProject] And add params to g:paginate in your view: <g:paginate params="${params}" ... > --------------------------- www.maf.org/rhoads www.ontherhoads.org On Tue, Feb 14, 2012 at 9:10 PM, antoaravinth <[hidden email]> wrote: > This questions seem to be repeated. But sorry for that, as a newbie to Grails > development, I'm getting worried with using paginate tag!. > > Here is what I want, I need to query all Tasks for a particular project! So > I came up writing this action : > > *def listMyProject(){ > def proj = params.managersProject > def project = Project.findByName("$proj") > def taskPagedResult = Tasks.createCriteria().list(max: params.max as > Integer, offset: params.offset as Integer) { > eq('project', project) > } > [tasksInstanceList: taskPagedResult, tasksInstanceTotal: > taskPagedResult.getTotalCount()] > }* > > My view file is : > > *<%@ page import="mnm.schedule.Tasks" %> > <!doctype html> > <html> > <head> > <meta name="layout" content="main"> > </head> > <body> > <div id="list-tasks" class="content scaffold-list" role="main"> > > Results > > <table> > <thead> > <tr> > > <th><g:message code="tasks.user.label" default="User" /></th> > > <g:sortableColumn property="completed" title="${message(code: > 'tasks.completed.label', default: 'Completed')}" /> > > <g:sortableColumn property="title" title="${message(code: > 'tasks.title.label', default: 'Title')}" /> > > <g:sortableColumn property="description" title="${message(code: > 'tasks.description.label', default: 'Description')}" /> > > <g:sortableColumn property="reason" title="${message(code: > 'tasks.reason.label', default: 'Reason')}" /> > > </tr> > </thead> > <tbody> > <g:each in="${tasksInstanceList}" status="i" var="tasksInstance"> > <tr class="${(i % 2) == 0 ? 'even' : 'odd'}"> > > <td><g:link action="show" id="${tasksInstance.id}">${fieldValue(bean: > tasksInstance, field: "user")}</g:link></td> > > <td><g:formatBoolean boolean="${tasksInstance.completed}" /></td> > > <td>${fieldValue(bean: tasksInstance, field: "title")}</td> > > <td>${fieldValue(bean: tasksInstance, field: "description")}</td> > > <td>${fieldValue(bean: tasksInstance, field: "reason")}</td> > > </tr> > </g:each> > </tbody> > </table> > <div class="pagination"> > <g:paginate total="${tasksInstanceTotal}" controller="project" action = > "listMyProject" /> > </div> > </div> > </body> > </html> > * > > This is not working properly. First I get the page where I can see the first > 10 results, with next and button appearing. But when I click on the next > button, I didn't see anything! I can see only the table been rendering > without the contents of it. After that when I click on previous button, I > get the same effect, only table been rendered. > > I'm a newbie to Grails, I'm with this problem for past two days! Please > kindly help me! > > ----- > Ant's > -- > View this message in context: http://grails.1312388.n4.nabble.com/Why-I-m-getting-such-a-bad-situation-using-pagination-in-Grails-tp4389444p4389444.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Oh thanks a lot bdrhoa :) :) Now it works.
Ant's
|
| Powered by Nabble | Edit this page |
