【发布时间】:2022-02-16 20:18:45
【问题描述】:
使用 Cakephp 4 我想显示一些数据。由于数据太多,我只想使用分页,我不想重新加载整个页面,只是显示这些数据的部分。所以我创建了一个这样的单元格: 文件Cell.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);
我在视图中显示分页,如下所示:
<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>
除了这样做我重新加载整个页面而我只想重新加载与单元格有关的部分之外,有人可以帮助我吗?
【问题讨论】:
-
使用 ajax 和一些 js 插件来加载和分页网站的那部分。
-
谢谢,我试试看。
标签: cakephp pagination cell