Hi,
As shown in the image above, I have the rows and pagination doesnt work properly as expected. Instead of showing 10 records per page(look at the pagination code below), it shows all the records in the same page and same record is showing in all the pages.
here is the code:
<!doctype html>
<g:applyLayout name="protocolNavigator">
<meta name="layout" content="page" />
<head>
<script type="text/javascript" src="<g:resource dir="BI/d3" file="d3.v2.js"/>"></script>
</head>
<content tag="listTitle">
<label>Data Activity</label>
</content>
<content tag="list">
<div id="div_print">
<table border="0" cellpadding="0" cellspacing="0" class="tablesorter">
<thead>
<tr>
<th>Study Id</th>
<th>Date</th>
<th>Start Time</th>
<th>Scheduler Name</th>
<th>Activity Description</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<g:each in="${data}">
<tr>
<td><g:remoteLink action="show" controller="DailyJobActivity" params='[id:"${it?.id}", name:""]' update="[success:'dataBox',failure:'error']" onSuccess="showDataBox()">${it?.study?.name}</g:remoteLink></td>
<!-- <td>${it?.provider}</td> -->
<td><g:remoteLink action="show" controller="DailyJobActivity" params='[id:"${it?.id}", name:""]' update="[success:'dataBox',failure:'error']" onSuccess="showDataBox()"><g:formatDate format="MMM dd, yyyy HH:mm" date="${it?.last_activity_datetime}"/></g:remoteLink></td>
<td><g:remoteLink action="show" controller="DailyJobActivity" params='[id:"${it?.id}", name:""]' update="[success:'dataBox',failure:'error']" onSuccess="showDataBox()"><g:formatDate format="MMM dd, yyyy HH:mm" date="${it?.started_datetime}"/></g:remoteLink></td>
<td></td>
<td><g:remoteLink action="show" controller="DailyJobActivity" params='[id:"${it?.id}", name:""]' update="[success:'dataBox',failure:'error']" onSuccess="showDataBox()">${it?.job}</g:remoteLink></td>
<td><g:remoteLink action="show" controller="DailyJobActivity" params='[id:"${it?.id}", name:""]' update="[success:'dataBox',failure:'error']" onSuccess="showDataBox()">${it?.current_status}</g:remoteLink></td>
</tr>
</g:each>
</tbody>
</table>
</div>
</content>
</g:applyLayout>
DailyJobActivity Controller is shown below.
<div class="bottoMenu">
<div class="pg">
<g:if test="${instanceTotal != null}">
<g:if test="${remotePagination == true}">
<util:remotePaginate action="${params.action}" params="${params}" total="${instanceTotal}" maxsteps="10" onSuccess="showDataBox()" update="[success:'dataBox',failure:'error']" />
</g:if>
<g:else>
<g:paginate maxsteps="10" action="${params.action}" total="${instanceTotal}" params="${params}"/>
</g:else>
</g:if>
</div>
</div>
<script>remotePagination
if (typeof (hideMsg) != "undefined")
hideMsg()
</script>
<g:applyLayout name="bottomOptionsnone">
package com.datumrite.sdtm
import java.text.SimpleDateFormat;
import com.datumrite.master.*;
import com.datumrite.BaseController
import com.datumrite.sdtm.Dailyjob
@Mixin(BaseController)
class DailyJobActivityController {
def commonService;
def view_name='/dataManagement/DailyJob'
def protoId
def providerId
def index() { }
def show(){
System.out.println "=== Activity ===";
def data = []
def job = Dailyjob.get(params.id as Long);
data = Dailyjobactivity.where {
daily_job == job
}.list([sort:'activity_datetime',order:'desc'])
System.out.println "=== Data ==="+data;
render(view:view_name+'/jobactivity',model:[data:data,instanceTotal:data.size()])
}
}
I have given the maxsteps as 10 .. and called accordingly.. But it is not getting reflected.
I want the no. of rows to be 10.. but it is more in this page as you see above.
can anyone help ? Thanks in advance.
From the Documentation
maxsteps (optional) - The number of steps displayed for pagination (defaults to 10). Used ONLY if params.maxsteps is empty
Note maxStep
is used for determining the number of pagination links not number of items/records.
For that you have to max
, again from the documentation
max (optional) - The number of records to display per page (defaults to 10). Used ONLY if params.max is empty
The important thing about max
is if there is a params.max
exists then g:paginate
will ignore this attribute. g:paginate
puts some properties like max
for number of records in per page, offset
for beginning index of records etc in params
. You have to use those while querying for data. For example your controller code can be li following
def show(){
System.out.println "=== Activity ===";
def data = []
def job = Dailyjob.get(params.id as Long);
//preparing max and offset from params
Integer max = params.max ? params.int("max") : 10
Integer offset = params.offset ? params.int("offset") : 0
data = Dailyjobactivity.where {
daily_job == job
}.list([sort:'activity_datetime', order:'desc', max: max, offset: offset])
System.out.println "=== Data ==="+data;
render(view:view_name+'/jobactivity',model:[data:data,instanceTotal:data.size()])
}