我有一个表,我想在其中使用分页,我的表数据由 Ajax 填充。
这是我正在使用的表格:
<div class="portlet box green Report index">
<div class="portlet-title">
<div class="caption"><i class="icon-globe"></i>Report Summary</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body">
<div id="content">
<table class="table table-striped table-bordered table-hover table-full-width" id="sample_1">
<thead>
<tr id='content2'>
<?php //echo $content_for_layout; ?>
<th><?php echo $this->Paginator->sort('name); ?></th>
<th><?php echo $this->Paginator->sort('clicks); ?></th>
<th><?php echo $this->Paginator->sort('conversions'); ?></th>
<th><?php echo $this->Paginator->sort('payout'); ?></th>
<th><?php echo $this->Paginator->sort('ltr'); ?></th>
<th><?php echo $this->Paginator->sort('cpc'); ?></th>
</tr>
</thead>
<tbody class="report_data">
</tbody>
</table>
</div>
</div>
</div>
在我看来,我有以下几点:
$this->Paginator->options(array(
'update' => '#content2',
'evalScripts' => true,
));
在我的控制器中,我记得有以下助手和组件:
public $components = array('RequestHandler');
public $helpers = array('Js' => array('Jquery'), 'Paginator');
在我的观点结束时,我补充说:
<?php echo $this->Js->writeBuffer(); ?>
现在,每当我单击其中一个表格链接时,网站都会重新加载,但有两个主要问题:
发送回分页器的数据不包含排序或顺序(也就是网站基本上只是重新加载)
该网站的渲染搞砸了(这是一个小问题,但仍然很烦人)
谁能告诉我我做错了什么?
蛋糕 2.3版
我的控制器
class ReportsController extends AppController
{
public $name = 'Reports';
public $components = array( 'BloglicHelper', 'RequestHandler', 'HasOffers');
public $helpers = array('Js' => array('Jquery'), 'Paginator');
public $paginate = array(
'fields' => array(
'Stat.clicks'
,'Offer.name'
,'Stat.currency'
,'Stat.conversions'
,'Stat.payout'
,'Stat.ltr'
,'Stat.cpc'
,'Stat.affiliate_id')
,'conditions' => array( 'Stat.affiliate_id' => array(
'conditional' => "EQUAL_TO",
'values' => array(1002)
)
, 'Stat.date' => array(
'conditional' => 'BETWEEN'
, 'values' => array(
)
),
),
'group' =>array('Offer.name'),
'Method' => 'getStats',
'totals' => true
);
public function index(){
$this->layout = 'client_layout';
}
public function ajax_index(){
if ($this->RequestHandler->isAjax())
{
$this->autoLayout = false;
$this->autoRender = false;
$this->layout = 'ajax';
}
//request selected dates
$startDate = $this->request->data['startDateTime'];
$endDate = $this->request->data['endDateTime'];
array_push($this->paginate['conditions']['Stat.date']['values'], $startDate, $endDate);
;
$finalData = array( 'table' => $this->paginate());
print json_encode($finalData);
}
}