我想知道如何仅在该页中排序表头而不排序整个表。这在cakephp中是可能的吗?请给我看一些示例代码。我的观点是
<?php
echo $url = $this->Paginator->sort('ID', 'id',array('direction' => 'desc'));
$arrow = getArrow($url);
?>
This is my Controller:
$this->paginate = Set::merge($this->paginate, array('OrderFinalized' => array(
'limit'=>4,
'conditions' => $condition_ary,
'joins' => array(
array(
'table' => 'order_entry_headers',
'alias' => 'OrderEntryHeaders2',
'type' => 'inner',
'foreignKey' => false,
'conditions' => array('OrderEntryHeaders2.id = OrderFinalized.order_entry_headers_id'),
'order' => array(
'OrderEntryHeaders2.id'=> 'desc'
)
),
这是查询:
$result = $this->OrderEntryHeader->query("SELECT (value+1) as val FROM order_entries_seq ORDER BY OrderEntryHeader.id desc ");
当我对第一页按降序排序时,我从数据库表中得到最后的结果。我只想对该页面的结果进行排序。它不应该在导航时改变。
ex- id name (page 1) ASC
12 B3 C4 D
DESC id名称4 D3 C2 B1
您需要的是从数据库检索数据,然后使用排序。最简单的方法是使用JavaScript。
您需要像
这样的前端/客户端表排序器 http://tablesorter.com/docs/演示仍然可以做排序函数吗?
在CakePHP中,可以在afterFind方法中进行数组排序