I have added a custom tab in customer admin view.

My tab class content is :

class Namespace_Modulename_Block_Adminhtml_Customer_Edit_Tab
extends Mage_Adminhtml_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface 
    public function __construct()

And in tab.phtml I have custom collection and want to add pagination.

How to add pagination for custom collection here?

2 Answers 2


I got a solution :

I created a grid.php in my custom module for custom collection and add grid in tab.phtml as below :

echo $this->getLayout()->createBlock('custom/adminhtml_path_grid')->toHtml();

Step1: Controller, First in our IndexController we will simply load the layout and render it.

class Excellence_Collection_IndexController extends Mage_Core_Controller_Front_Action
    public function indexAction()


Step2: Layout, In our module layout file, i.e collection.xml this is the code to put

<?xml version="1.0"?>
<layout version="0.1.0">
        <reference name="content">
            <block type="collection/collection" name="collection" template="collection/collection.phtml" />

Step3: Block, Next we will create our block collection/collection where the main code for paging goes.

class Excellence_Collection_Block_Collection extends Mage_Core_Block_Template

    public function __construct()
        $collection = Mage::getModel('collection/collection')->getCollection();

    protected function _prepareLayout()

        $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
        $this->setChild('pager', $pager);
        return $this;

    public function getPagerHtml()
        return $this->getChildHtml('pager');

As you can see in the above code we have created a block for the pager and set our collection in it. Step4: phtml file, Next in our collection.phtml file we need to put in this code

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<?php $collection = $this->getCollection(); ?>
<div class="page-title">
    <h1><?php echo $this->__('My Collection') ?></h1>
<?php echo $this->getPagerHtml(); ?>
<?php if($collection->getSize()): ?>
<table class="data-table" id="my-custom-table">
    <col width="1" />
    <col width="1" />
    <col />
    <col width="1" />
    <col width="1" />
    <col width="1" />
            <th><?php echo $this->__('ID #') ?></th>
            <th><?php echo $this->__('Title') ?></th>
            <th><span class="nobr"><?php echo $this->__('Created') ?></span></th>
        <?php $_odd = ''; ?>
        <?php foreach ($collection as $_obj): ?>
            <td><?php echo $_obj->getCollectionId() ?></td>
            <td><span class="nobr"><?php echo $_obj->getTitle(); ?></span></td>
            <td><?php echo $this->formatDate($_obj->getCreatedTime()) ?></td>
        <?php endforeach; ?>
<script type="text/javascript">decorateTable('my-custom-table');</script>
<?php echo $this->getPagerHtml(); ?>
<?php else: ?>
    <p><?php echo $this->__('The collection is empty.'); ?></p>
<?php endif ?>

This is all that is required, now the paging should show up on your collection.

Showing Toolbar on Custom Collection Now we will add a toolbar to our custom collection, i.e will add sorting and view modes. Here is the end result of the code

enter image description here

  • I will try it and will let you know. Jan 7, 2017 at 13:51
  • ok sure.........let me know if you have any issue with that. Jan 7, 2017 at 20:44
  • Hello, I tried but it is not working, this is working in frontend template but as I said I have to implement it is in admin panel in customer section where I added a custom tab. Jan 9, 2017 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.