我是grails的新手,我正在尝试在应用程序中实现分页。
我已经按照文档中的示例进行了操作,但是似乎没有任何反应,它无法呈现页面导航按钮。这是示例代码:

def transaction = DataEntry.findAll() as List
    render(model: [transactions: transaction, total: transaction.count ], view: "/Transactions/verify")

然后我认为这是这样的:
<g:each var="transaction" in="${transactions}">
    <h1>${transaction.sendersName}</h1>
</g:each>

<g:paginate next="Forward"
            prev="Back"
            maxsteps="1"
            controller="approvedTransaction"
            action="index"
            total="${total}" />

任何帮助都感激不尽!

最佳答案

检查这个例子

域类:

class DataEntry{
    String sendersName
}

Controller :
class TransactionsController {
    def list() {
        [data: DataEntry.list(params), dataEntryCount: DataEntry.count()]
    }
}

分页代码:
<g:paginate controller="transactions" action="list" total="${dataEntryCount}" />


<g:paginate next="Forward" prev="Back"
            maxsteps="0" controller="transactions"
            action="list" total="${dataEntryCount}" />

请参考documentation了解更多详情

07-24 09:37
查看更多