我想知道如何只在该页面中排序表头,而不排序整个table.is这可能在cakephp?请给我看一些示例代码。我的意见是
<?php echo $ url = $ this-> Paginator-> sort 'ID','id',array('direction'=>'desc')); $ arrow = getArrow($ url); ?> 这是我的控制器: $ this-> paginate = Set :: merge($ this-> paginate,array('OrderFinalized'=> array 'limit'=> 4,'conditions'=> $ condition_ary,'joins'=& ('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);当我排序第一页的顺序,我得到最后的结果从数据库table.i想
exid_id名称(第1页)ASC 1 A 2 B 3 C 4 D
DESC ID名称 4 D 3 C 2 B 1 A
解决方案你想要的是从数据库中检索数据,然后使用排序。最简单的方法是使用JavaScript。
您需要前端/客户端表格排序器,如
tablesorter/docs/#Demo
$ b这是可能在CakePHP ,请在数组排序中a href =book.cakephp/2.0/en/models/callback-methods.html#afterfind =nofollow> afterFind方法
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
解决方案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
tablesorter/docs/#Demo
is it still possible to do with sort function?
It is possible in CakePHP, make array sort in afterFind method
更多推荐
按降序排序表头,无需排序整个数据库表
发布评论