Deskripsi
Cara membuat pagination yang disertai ajax, jadi kita ga perlu melakukan refresh page, lumayan mudah.
Howto
controller (in your action) :
$this->paginate=array('fields'=>array('model.field1','model.field2'),
'limit'=>100,
'order'=>array('model.field1'),
'conditions'=>array('model.field1'=>'yeah')
);
$Data=$this->paginate('model');
$this->set('viewData',$Data);
View :
// on the top of your div table
<?php
$this->Paginator->options(array(
'update' => 'content', // disable this make your pagination without ajax (normal pagination), wrong value parameter can make all of your javascript disable (like jquery bootstrap dll ... ) so its recommend to not use ajax pagination.
'evalScripts' => true,
'before' => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer' => false)),
'complete' => $this->Js->get('#busy-indicator')->effect('fadeOut', array('buffer' => false)),
));
?>
// on the top of table , for pagination number
<div id="paging">
<?php
echo $this->Paginator->prev('« Sebelumnya', array('escape' => FALSE));
echo ' |';
echo $this->Paginator->numbers(array('separator' => false));
echo '| ';
echo $this->Paginator->next('Selanjutnya » ', array('escape' => FALSE));
?>
</div>
//sample table body
<?php foreach($data as $viewData): ?>
<tr>
<td><?php echo $data ['XXX']['YYY']?></td>
</tr>
<?php endforeach ?>
//on the bottom of div table
<?php echo $this->Js->writeBuffer(); ?>
Post a Comment
Harap gunakan bahasa yang baik dan sopan, terima kasih