Book Image

Magento PHP Developer????s Guide, 2nd Edition

By : Allan MacGregor
Book Image

Magento PHP Developer????s Guide, 2nd Edition

By: Allan MacGregor

Overview of this book

Table of Contents (16 chapters)
Magento PHP Developer's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The grid widget


Instead of having to write our own grid blocks from scratch, we can reuse the ones that are already provided by the Magento Adminhtml module.

The block that we will be extending is called the grid widget. The grid widget is a special type of block designed to render a collection of Magento objects in a particular table grid.

A grid widget is normally rendered inside a grid container. The combination of both elements not only allows us to display our data in grid form, but also adds search, filtering, sorting, and mass action capabilities. Perform the following steps:

  1. Navigate to the block's Adminhtml/ folder and create a folder named Giftregistry/.

  2. Create a class called List.php inside that folder.

  3. Copy the following code inside List.php, located at app/code/local/Mdg/Giftregistry/Block/Adminhtml/Customer/Edit/Tab/Giftregistry/List.php:

    <?php
    class Mdg_Giftregistry_Block_Adminhtml_Customer_Edit_Tab_Giftregistry_List extends Mage_Adminhtml_Block_Widget_Grid
    {
      public function...