2012-06-18 50 views
0

我已加入显示多个表格的截图。我希望分页程序可以使用多个“显示”表格,尽管它们都来自相同的查询。请注意,“Id”列是多列中的一列。在我看来CakePHP:一次排序多个HTML表格

var $paginate = array(
      'limit' => 1000); 

    function index() { 
      $this->Immeuble->recursive = 1; 
      $this->Immeuble->contain('Agence'); 
      $this->set('results', $this->paginate()); 
      $agences = $this->Immeuble->find('count', array('fields' => 'DISTINCT Agence.Nom')); 
      $this->set('agences',$agences); 
      $ii = 0; 
      $records = $this->Immeuble->find("all",array('fields'=>'Immeuble.id,Immeuble.image,Immeuble.description,Immeuble.start_date,Immeuble.end_date$ 
      $this->set('records',$records); 
      } 

这里我分页程序部分:

<tr> 
         <th><?php echo $this->Paginator->sort('Id','id'); ?></th> 
         <th><?php echo $this->Paginator->sort('description');?></th> 
         <th><?php echo $this->Paginator->sort('start_date');?></th> 
         <th><?php echo $this->Paginator->sort('end_date');?></th> 
         <th><?php echo $this->Paginator->sort('image');?></th> 
         <th><?php echo $this->Paginator->sort('ordre');?></th> 
         <th><?php echo $this->Paginator->sort('agence_id');?></th> 
         <th class="actions"><?php __('Actions');?></th> 
</tr> 

Sorting won't work, it'll just order ASC, not DESC.

+0

按压锚点时,paginator只是无法整理。尽管小箭头会显示出来,网址也会改变。 –

+0

您是否在使用'$ results'来显示*全部*数据? '$ records'不会被分页/正确排序,因为你没有使用Controller :: paginate()来找到它们(你可以和它将使用相同的请求排序)。 – jeremyharris

+0

我该如何申报另一个分销商?它不只是覆盖我已经设置的参数? –

回答

1

您可以使用分页多次,因为它只是一个查找调用。它将重用Cake传递的参数。

$records = $this->paginate(); 

如果需要,您可以将特殊条件传递给此调用。