With Cakephp 4 I would like to display some data. As there is too much data I would like to use pagination only I don't want to reload the whole page, just the part that displays this data. So I created a cell like this: fileCell.php
public function display() {
$results = $paginator->paginate(
$query,
$this->request->getQueryParams(),
[
'limit' => 20
]
);
}
$paging = $paginator->getPagingParams() + (array)$this->request->getParam('paging');
$this->request = $this->request->withParam('paging', $paging);
$this->set('res', $results);
and I display the pagination in my view like this:
<div class="instances index content">
<div class="paginator">
<ul class="pagination">
<?= $this->Paginator->first('<< ' . __('first')) ?>
<?= $this->Paginator->prev('< ' . __('previous')) ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->next(__('next') . ' >') ?>
<?= $this->Paginator->last(__('last') . ' >>') ?>
</ul>
<p><?= $this->Paginator->counter(__('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')) ?></p>
</div>
</div>
Except that by doing so I reload the whole page while I would like to reload only the part concerning the cell, can someone help me?
I made a standard ajax call, I create function in my controller. I create view associate corresponding to my element. In my main view (where I will place my element), I add div :
<div id="test">
</div>
And, in my ajax response I add :
$('#test').html(response);
After that, I manage the pagination of my element normally with cakephp pagination.