1

このページネーションの問題を解決するために 1 週​​間を費やしましたが、良い結果は得られませんでした。

私は私のコントローラにこれを持っています

    PatientController{
    def show(Long id) {
    def patientInstance = Patient.get(id)
    if (!patientInstance) {
        flash.message = message(code: 'default.not.found.message', args: [message(code: 'patient.label', default: 'Patient'), id])
        return
    }



    def historyInstance = History.findAllByPatient(patientInstance)
    def total = historyInstance.size()


    [historyInstance: historyInstance,patientInstance: patientInstance,historyInstanceTotal: total]


    }
}

そして、私はビューにこのコードを持っています

    <g:each in="${historyInstance}" var="historyInstances" status="i">
      ...
    </g:each>

    <div class="pagination">
        <g:paginate  total="${historyInstanceTotal}"/>
    </div>

paramsの最大値を使用し、<g:paginate>すべてを試しましたが、結果が得られず、常にビューに履歴のセット全体が表示されます。

4

1 に答える 1

5

使用しているファインダーにyour を渡す必要がありparamsます。そうしないと、ページネーションの方法がわかりません。この<g:paginate>タグは、ページネーション リンクを表示するためだけのものであり、実際にページネーションを実行するわけではありません。また、結果セットは結果の現在のページに限定されるため、totala を使用する必要があります。countBy

def historyInstance = History.findAllByPatient(patientInstance, params)
def total = History.countByPatient(patientInstance)
于 2013-07-23T18:44:53.230 に答える