在Cakephp 4中,我想显示一些数据。由于数据太多,我只想使用分页,我不想重新加载整个页面,只想重新加载显示这些数据的部分。因此,我创建了一个单元格,如下所示: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);
并在视图中显示分页,如下所示:
<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>
除了这样做,我重新加载整个页面,而我想重新加载有关细胞的部分,有人能帮助我吗?
2条答案
按热度按时间lztngnrs1#
我只是Cake的初学者,但我想知道控制器中的
finder
函数是否可以接受页面参数?我没有例子,但我很快就会做类似的事情。
wh6knrhe2#
我 做 了 一 个 标准 的 ajax 调用 , 在 我 的 控制 器 中 创建 函数 , 创建 与 我 的 元素 相 对应 的 视图 , 在 我 的 主 视图 中 ( 我 将 放置 我 的 元素 ) , 添加 div :
中 的 每 一 个
而且 , 在 我 的 ajax 响应 中 , 我 补充 道 :
格式
之后 , 我 通常 使用 cakephp 分页 来 管理 元素 的 分页 。