问题
I would like to know how to sort a table header only in that page without sorting the whole table.is this possible in cakephp? please show me some sample code. my view is
<?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'
)
),
this is the query:
$result = $this->OrderEntryHeader->query("SELECT (value+1) as val FROM order_entries_seq ORDER BY OrderEntryHeader.id desc ");
When I sort the first page desending order I get the last results from the database table.i want to sort only the results from that page.it should not change while navigation.
ex- id name (page 1) ASC
1 A
2 B
3 C
4 D
DESC id name 4 D 3 C 2 B 1 A
回答1:
What you want is to retrieve data from a database and then use the sorting. The easiest way is by using JavaScript.
You need front-end / client-side table sorter like
http://tablesorter.com/docs/#Demo
is it still possible to do with sort function?
It is possible in CakePHP, make array sort in afterFind method
来源:https://stackoverflow.com/questions/33085862/sort-table-header-in-descending-order-page-wise-without-sorting-whole-database-t