Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AJAX pagination in Zend Framework

How do you display AJAX paginated data using Zend_Framework?

  • Are there any good examples using paginationControl(), ajaxLink() and ajaxContext() helpers?
  • Would you share your implementation?
like image 349
takeshin Avatar asked Nov 05 '22 12:11

takeshin


1 Answers

you can use table with simple paginations with : https://www.datatables.net/

Here is an example :

controller :

<?php
class ExampleController extends Zend_Controller_Action
{
    public function init()
    {
        /* Initialize action controller here */
    }
    public function indexAction()
    {
        // action body
        $this->view->headTitle()->append('Example');
        //populate database tables
        $example = new Application_Model_ExampleMapper();
        $this->view->entries = $example->fetchAll();
    }
}

view :

<script>         
$(document).ready(function() {
    $('#example').dataTable();
} );
</script>
<table class="display dataTable" id="exampledtable" >
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Field1</th>
                    <th>Field2</th>
                    <th>Field3</th>
                </tr>
             </thead>
         <tbody><?php foreach ($this->entries as $entry): ?>
            <tr>
                <td><?php echo $this->escape($entry->ID) ?></td>
                <td><?php echo $this->escape($entry->field1) ?></td>
                <td><?php echo $this->escape($entry->field2) ?></td>
                <td><?php echo $this->escape($entry->field3) ?></td>
            </tr>
        <?php endforeach ?>
    </tbody>
</table>
like image 107
Mimouni Avatar answered Nov 11 '22 08:11

Mimouni